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
Presentation Graphics The instant you are going to represent yourself or your product or company or research paper and so on. Only standing and speaking is fairly ineffective.

What is Multimedia: People only remember 20 percent of what they see and 30 percent of what they hear. But they keep in mind 50 percent of what they see and hear and as much as 80

Determine the advantages of raster-scan systems (i)  Rasterisation is now performed faster since a special purpose processor is used. (ii)  The CPU is not slowed down by the

Question: (a) A statistical encoding algorithm is being considered for the transmission of a large number of long text files over a public network. Part of the file content i

Well you might surprise to what a convex window? In common, on the basis of the shapes the windows are categorized into two classes: i) A Convex shaped windows: Windows of a s

What is translation?  Translation is the process of changing the position of an object in a straight-line path from one coordinate location to another. Each point (x, y) in the

Geometric continuity - Properties of Bezier Curves Geometric continuity is the other process to join two successive curve sections. G 0 continuity is the similar as parametri

Define  Aspect ratio- Aspect ratio: The ratio of vertical points to horizontal points necessary to produce equal –length lines in both directions on the screen, is called as


Cel Animation - Computer Animation Making an animation by using this method, all characters are drawn on a separate piece of transparent paper. Also a background is drawn on a