Question #36940

Create a class point with xcod and ycod as data members.include member functions to read and print the coordinate values as get point() and show point() respectively. write a main method to demonstrate point class
1

Expert's answer

2013-11-15T13:05:40-0500
#include <iostream>
#include <conio.h>
using namespace std;
class Point
{
public:
    int GetPointX() const { return xcod; }
    int GetPointY() const { return ycod; }
    void SetPoint(int newX, int newY)
    {
        xcod = newX;
        ycod = newY;
    }
private:
    int xcod;
    int ycod;
};
int main()
{
    Point point;
    cout << "So we created an object 'point'" << endl;
    cout << "Let's set coordinates 3 and 5 to X and Y respectively" << endl;
    point.SetPoint(3,5);
    cout << "We can check it's coordinates: " << endl;
    cout << "X = " << point.GetPointX() << endl;
    cout << "Y = " << point.GetPointY() << endl;
    _getch();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS