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
What do you mean by emissive and non-emissive displays?  The emissive display changes electrical energy into light energy. The plasma panels, thin film electro-luminescent disp

what is region filling? give details

GIF File Compression The Graphic Interchange Format file format utilizes a relatively basic form of file compression which squeezes out inefficiencies within the data storage w

what is ray tracing algorithm in hidden surface removal

Advantages of Scan line Algorithm:   This time and always we are working along with one-dimensional array as: x[0...x_max] for color not a 2D-array like in Z-buffer algorithm.

Write a program that allows interactive manipulation of the position and orientation of a camera. Draw a teapot at the global origin 0,0,0. You can find a shaded teapot model and

Characteristics of Bitmap Data: Bitmap data can take up many rooms. A CMYK A-4 size picture which is optimized for medium quality printing (150 lpi) takes up 40 Mage Bytes. Compre

what is physx?