c++ programming, Computer Graphics

Assignment Help:
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 ;
}

Related Discussions:- c++ programming

Explain the role of the prefight personnel, QUESTION a) Once a print jo...

QUESTION a) Once a print job is accepted by the print service provider, it will be assigned a job number and this information will become part of a printed job ticket, which wi

List out the merits and demerits of penetration methods, List out the merit...

List out the merits and demerits of Penetration methods?  The merits and demerits of the Penetration methods are as follows  It is a less expensive technique It has

Vecgen algorithem for line, explain vecgen algorithem for line drawing in c...

explain vecgen algorithem for line drawing in computer graphics

Interpolation of surface - polygon rendering, Interpolation of surface - Po...

Interpolation of surface - Polygon Rendering Interpolation of surface normals beside the polygonedge between two vertices is demonstrated above in the figure 15. Here the norm

Illustration, mcqs of illustration in nts test

mcqs of illustration in nts test

Write a c code for generating concentric circles, Write a C code for genera...

Write a C code for generating concentric circles.  Put the circle function circleMidpoint()in a for loop  as follows: for( int radius = MinRadius; radius circleMidpoint(i

Languge, what languge do computers speak

what languge do computers speak

Line drawing - points and lines, Line Drawing - Points and lines Line ...

Line Drawing - Points and lines Line drawing is accomplished through computing the intermediate point coordinates along the line path between two given end points. Since, scre

Physx, what is physx.?

what is physx.?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd