|
|
//Vectors of objects
#include "stdio.h"
class point
{
private:
int x1,x2;
void init(int x, int y)
{
x1=x;
x2=y;
}
public:
point(int x, int y){ x1=x; x2=y;}
point(){ init(0,0);}
int x_cord(){ return x1;}
int y_cord(){ return x2;}
};
int main()
{
1 point data(3,4);
2 printf("\n The y coordinate = %d", data.y_cord());
3 point more_data[20];
4 printf("\n The x coordinate of index 18 = %d",more_data[18].x_cord());
return 0;
}
带标号的4个语句造成的。哪位给讲解一下?偶是新手。 |
|