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

Uncompressed and common audio format, Uncompressed / Common Audio Format ...

Uncompressed / Common Audio Format There is one main uncompressed audio format: PCM. It is generally stored like a .wav on Windows. WAV is file format which is flexible and des

Area filling algorithms - output primitives, Area Filling Algorithms Be...

Area Filling Algorithms Before we go ahead with area filling algorithms, a word about pixel addressing and object geometry. You know that line segments are discretized into fin

Illustration of a clipping window - raster graphics, Illustration of a Clip...

Illustration of a Clipping window ABCD is placed as follows: A (100, 10), B (160, 10, C (160, 40), D (100, 40) By using Sutherland-Cohen clipping algorithm determine the vis

Polygon representation methods - space partitioning, Polygon representation...

Polygon representation methods - Space Partitioning Representations Space partitioning representations: this type of representation is used for explain the interior pr

Description of the particularities of each drawing style, Question: (a)...

Question: (a) There are 3 main industries of drawing style and it has become a phenomenon. It was inspired by internationally diffused cartoons, comic strip books and since the

Perspective distortion - ray tracing methods , Perspective Distortion - Pol...

Perspective Distortion - Polygon Rendering and Ray Tracing Methods Anomalies are introduced since interpolation is performed after perspective transformation in the 3-D scree

Gui and graphics, Newspapers exchange news by using news agencies (such as ...

Newspapers exchange news by using news agencies (such as Reuters and ITARTASS). A newspaper registers at a news agency and sends all its news to the agency. The news agency collect

Explain clearly how to view the baseline grid, QUESTION (a) What are th...

QUESTION (a) What are the main purposes of using master pages? (b) How do you select a master page item on a document page? (c) How do you resize a graphics frame and its

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