#include<iostream>
using namespace std;
class exam
{
int x;
public:
void setx(int n)
{x=n;}
int getx()
{return x;}
};
void main()
{
exam ob[4];
int i;
for(i=0;i<4;i++)
ob[i].setx(i);
for(i=0;i<4;i++)
cout<<ob[i].getx()<<endl;
}
给类中无自定义构造函数的对象数组赋值
最新推荐文章于 2022-10-06 11:15:22 发布