c++ programming, Computer Graphics

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; teh second member of the pair is to be 0.
Overload biinary 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

istream& operator >> (istream& ins, Pairs& second)
{
char ch;
ins >> ch; // discard initial ''(''
ins >> second. f;
ins >> ch; // discard comma '', ''
ins >> second. s;
ins >> ch; // discard final '') ''
return ins;
}
ostream& operator << (ostream& outs, const Pairs& second)
{

outs << ''( '';
outs << second. f;
outs << '', ''; // you might prefer ", "
// to get an extra space
outs << second. s;
outs << '')'' ;
return outs ;
}
Posted Date: 3/21/2013 3:51:32 PM | Location : United States







Related Discussions:- c++ programming, Assignment Help, Ask Question on c++ programming, Get Answer, Expert's Help, c++ programming Discussions

Write discussion on c++ programming
Your posts are moderated
Related Questions
Sequence of Steps to Generate a Full Animation The sequence of steps to generate a full animation would be as given below: 1)  Improve a script or story for the animation.

WHAT THAT S MEANS 0001

Which is the most usable and frequent method to generate a character?

What is shearing?  The shearing transformation actually slants the object with the X direction or the Y direction as needed.ie; this transformation slants the shape of an obje

Homogeneous Coordinate Systems - 2-d and 3-d transformations Suppose P(x,y) be any point in 2-D Euclidean (Cartesian) system. In HC System, we add a third coordinate to a poin

Visible-Surface Detection For the generation of realistic graphics display you know that hidden surfaces and hidden lines should be identified for removing. For this reason we

Object Space - approaches for visible surface determination The second approach as object-space that compares all objects directly along with each other inside the scene defin

2-D and 3-D Transformations Previously, we have presented approaches for the generation of polygonal regions and lines. We identified that once the objects are produced, the v

Hypertext: it is conceptually very similar as regular text: it can be stored, searched, read, or edited along with a significant difference: hypertext is text along with pointers

are you a robot