结构体构造函数实现实例。
在这里插#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
struct point{
int x;
int y;
point(){}
point(int _x, int _y) :x(_x), y(_y){}
}pt[10];
int main(){
int num=0;
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
pt[num++] = point(i, j);
}
}
for (int i = 0; i < num; i++){
printf("%d,%d\n", pt[i].x, pt[i].y);
}
system("pause");
return 0;
}入代码片