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
LCD - Liquid Crystal Display A liquid crystal display consists of two glass plates each containing a light polarizer. One glass plate contains vertical polarizer and the ot

Remember in polygonalization of the surface, following rules must be followed. Any two polygons  (i)  share a common edge,   (ii)  Share a common vertext,  (iii)  Arc disj

Applications that can handle Bitmap Data Hundreds of applications are there in the market which can be used to modify or make bitmap data. For illustration: Adobe Photo Shop, C

Write a C program to create a window of specified size and position and draw the following objects with dimensions of your choice, to fit within the window.   (a) A point  (b) A

What do you mean by scan conversion?  A main task of the display processor is digitizing a picture definition given in an application program into a set of pixel-intensity valu

3Dstudio - Softwares for computer animation 3DStudio is a 3-D computer graphics programmed. 3DStudio runs on personal computers. This is relatively simple to use. Several schoo

a__________of a scene is apart of a scene by which relate one part of the scene with the other parts of the scene

What is meant by Addressability? Ans. Addressability is the number of individual dots per inch (d.p.i.) that can be formed. If the address of the current dot is (x, y) then the

Find out the matrix of projection for cavalier projection Answer: Cavalier projection corresponds to tan α = 1, leading to the following matrix.

3DStudio Max -Softwares for computer animation The successor to 3-DStudio 3.0, 3-DStudio Max runs in WindowsNT. This is completely object-oriented, featuring new enhancements a