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
Transformation for 3-D Rotation Rotation in 3-dimensions is considerably more complicated then rotation in 2-dimensions. In 2-Dimentional, a rotation is prescribed via an angl



To reflect the ball off of the polyline, we need to re?ect it off of the segment that had the minimum thit. But the reflection computation depends only on t hit , n, P and v, so th

Introduction of Visible Surface Detection For displaying a realistic presentation of the given 3Dimentional object, hidden surfaces and hidden lines should be identified fo

what is the working procedure of CRT with diagram

What is character generation and explain it''s two method: 1> Bitmap method 2> outline method.

Write a polygon clipping algorithm to clip a polygon against rectangular clipping are. Read the vertices of polygon to be clipped. 2. Read the coordinates of the rectangular cl

Procedural Animation - Computer Animation This category of animation is utilized to produce real time animation that permits a more diverse series of actions to occur. These a

Question: A curve shape has three quadratic Bézier curve segments. The curves have been joined sequentially so that continuity of the first derivative of the resulting curve sha