Please help

class orderedPair
{
public :
void setX ( double a );
void setY ( double b );
double getX ();
double getY ();
void print (); // Prints the ordered pair (x, y)
private :
double x;
double y;
};

int main ()
{
orderedPair * pairPtr ;
pairPtr = new orderedPair ;
// line a
// line b
// line c
}

a. Write the missing code i line a to assign 5 to the x-coordinate of the ordered
pair.
b. Write the missing code in line b to assign 7 to the y-coordinate of the ordered
pair.
c. Write the missing code in line c to print out the ordered pair
Yep, waiting for you to do it :+) It's not hard :+)

Should have a constructor.

orderedPair* pairPtr = new orderedPair ;

Edit : You should probably stop posting your homework without any effort, no one will reply.
Last edited on
What do you think are these functions for ?
1
2
3
void setX ( double a );
void setY ( double b );
void print (); // Prints the ordered pair (x, y) 
Someone please explain how to call the x and y coordinate
What do you mean by "call"?
If used abstractly than you can use the access function of get x and get y. If you need it for one of the class function it should be straight forward
a) pairPtr->set(5)
b) pairPtr->set(7)
c)

I do not know how to print c
The class orderedPair has one public member function that has a comment. What does that comment say about the function?
can someone please tell me if this is correct
a) pairPtr->set(5)
b) pairPtr->set(7)
c) void print (x,y)
1
2
a) pairPtr->setX(5);
b) pairPtr->setY(7);

To print just call the function print of the pairPtr pairPtr->print();

Who wrote the class for you?
Topic archived. No new replies allowed.