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
Computer Animation Tools  To create various types of animation discussed above, we want to have particular software and hardware as well. Here, the fundamental constraint is re

MULTIMEDIA TOOLS : In this sense, we will emphasize on various tools utilized in the field of multimedia. Basic Tools: The fundamental toolset for building multimedia p

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

computer animation Note : This is to be noticed that computer animation can also be produced by changing camera parameters as its position, orientation and focal length, as w

Perform the indicated base conversions 548 to base 5

Define polygon?  A polygon is any closed continues sequence of line segments i.e., a polyline whose last node point is similar as that of its first node point. The line segment

What is uniform rational splines

Working of vecgen algorithm with diagram

Example: Exemplify the Bresenham line generation algorithm through digitizing the line along with end points (20, 10) and (30, 18) Solution: m =    (y2 - y1)/( x2 - x1)  =

Use of Interactive Multimedia in Education Virtual reality, where 3-D experimental training can simulate real situations. Computer simulations of things too expensive,