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

You, are you a robot

are you a robot

File formats that are used for vector data, File Formats that are used for ...

File Formats that are used for Vector Data This data can be saved in a wide variety of file formats are as: •EPS: the most well-accepted file format to exchange vector dra

Basic approaches for visible surface determination, Basic Approaches for Vi...

Basic Approaches for Visible Surface Determination There are two basic approaches for visible-surface determination, as per if they deal along with their projected images or a

Objectives of curves and surfaces - modeling and rendering, Objectives of C...

Objectives of Curves and surfaces - modeling and rendering After going through the section, you should be capable to: Implement the methods utilized to represent a pol

Region filling, what is region filling? give details

what is region filling? give details

Categories of parallel projection - viewing transformation, Categories of P...

Categories of Parallel Projection Parallel projection can be categorized as per to the angle which the direction of projection makes along with the projection plane. For illu

Positive accelerations - computer animation, Positive Accelerations - Compu...

Positive Accelerations - Computer Animation So as to incorporate increasing speed in an animation the time spacing among the frames should increase, hence greater change in th

Perspective projection, Perspective Projection 1. Perspective projectio...

Perspective Projection 1. Perspective projection gives more realistic appearance and uses the same principle as used in camera. 2. Perspective projection is not an affine tr

Line drawing display - random scan display device, Line Drawing Display - R...

Line Drawing Display - Random Scan Display Device The display through this system is termed as Line Drawing Display. The sequence controls the subsequent stages, demonstrated

Storing information structures in display memory, What is the major disadva...

What is the major disadvantages of storing information structures in display memory? A major disadvantage of storing information structures in display memory is that when color an

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