#include<iostream>
using namespace std;
class A
{
private:
int a;
public:
A() {a=0;}
A (int aa){a=aa;} // , aa a
};
void main()
{
A *p; // A p
p=new A(5);// p
system("pause");
}
#include<iostream>
using namespace std;
class A
{
private:
int *a;
int n;
int MaxLen;
public:
A(): a(0), n(0), MaxLen(0) {}
~A();
A(int *aa, int nn, int MM);
int GetValue(int i) {return a[i];}
};
A::A(int *aa, int nn, int MM)
{
n=nn;
MaxLen=MM;
if(n>MaxLen) exit(1);
a=new int[MaxLen];
for(int i=0;i<MaxLen;++i) // i aa a
{
a[i]=aa[i];
}
}
A::~A ()
{
delete []a; // , a
}
void main()
{
int b[10]={1,2,3,4,5,6,7,8,9,10};
A r(b,10,10);
int i,s=0;
for( i=0;i<10;i++) // i , r a s
{
s+=r.GetValue(i);
}
cout<<"s="<<s<<endl;
system("pause");
}
。 ? for , , !! , !!! s=55; ~~