65,184
社区成员




//2011.3.22
//Code::Blocks vs2010
#include <iostream>
using namespace std;
/////////////////////////////////////////////////////////
class Ctemp
{
public:
Ctemp(int (*piarr)[3], double dtemp) : dscore(dtemp)
{
memcpy(inum, piarr, sizeof(int)*3);
}
void display()
{
for(int i = 0; i != 3; ++i)
{
cout << inum[i];
}
cout << " " << dscore << endl;
}
private:
int inum[3];
double dscore;
};
/////////////////////////////////////////////////////////
int main()
{
int a[3] = {1,2,3};
int b[3] = {4,5,6};
int c[3] = {7,8,9};
Ctemp cta[3] = {Ctemp(&a, 1.1),Ctemp(&b, 1.2),Ctemp(&c, 1.3)};
for(int i = 0; i != 3; ++i)
{
cta[i].display();
}
system("pause");
return 0;
}
/*
123 1.1
456 1.2
789 1.3
请按任意键继续. . .
*/