|
The sentence you said is wrong, and the other is wrong, it should be like the following !!!!!!!
#include <iostream.h>
class Location {
private:
int X, Y;
public:
void init (int initX, int initY);
int sumXY ();
};
void Location :: init (int initX, int initY)
{
X = initX;
Y = initY;
}
int Location :: sumXY ()
{return X + Y;}
void main ()
{Location A1;
int x, y;
A1init (5,3);
x = A1.X, y = A1.Y; // At this time, the object cannot access the private properties of the class and cannot be assigned this way. This statement should be deleted.
cout << x + y << "" << A1.sumXY () << endl;
} |
|