Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 405 Weeks Ago, 6 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 14 Sep 2017 My Price 87.00

Im pretty stuck,

So Im pretty stuck,Ill put the question down below and the code I have. It asks you to complete the self test 17, which I think I did, but for some reason i can get it to work. Anyways, any help would be great:

self-test exercise 17 asked you to overload the operator >> and the operator << for a class pairs. Complete and test this exercise. Implement the default constructor and the constructors with one and two int parameters. The one parameter constructor should initialize the first member of the pair; the second member of the pair is to be 0.
Overload binary operator to add pairs according to the rule
(a, b) (c, d) = (a c, b d)
Overload operator- analogously.
Overload operator* on pairs and int according to the rule
(a, b)*c= (a*c, b*c)
Write a program to test all the member functions and overloaded operators in your class definition.

And this is the code I have for self test 17 which I cant get to work:

#include <iostream>

using namespace std;

class Pairs

{

public:

Pairs () ;

Pairs(int first, int second);

friend istream& operator >>(istream& ins, Pairs& second);

friend ostream& operator <<(ostream& outs, const Pairs& second);

private:

int f;

int s;

};

istream& operator >>(istream& ins, Pairs& second)

{

char ch;

ins >> ch;

ins >> second.f;

ins >> ch;

ins >> second.s;

ins >> ch;

return ins;

}

ostream& operator <<(ostream& outs, const Pairs& second)

{

outs << '(';

outs << second.f;

outs << ',';

outs << second.s;

outs << ')';

return outs;

}

Answers

(5)
Status NEW Posted 14 Sep 2017 08:09 PM My Price 87.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)