![]() |
#2
lz10919149992012-02-18 19:05
|

#include "stdafx.h"
#include <iostream>
using namespace std;
class CA
{
public:
CA(){cout<<"This is the constructor of CA"<<endl;}
~CA(){cout<<"This is the destructor of CA"<<endl;}
};
class CB
{
CA a;//只知道这里是类的组合
public:
CB(){cout<<"This is the constructor of CB"<<endl;}
~CB(){cout<<"This is the constructor of CB"<<endl;}
};
void fun(int n)
{
static CA a;//这里不清楚为啥定义静态
CB b;
cout<<"n="<<n<<endl;
}
void main()
{
fun(10);
fun(20);
CA *A;//这里不明白
CB *pb=new CB;//这里也是
delete pb;
}
#include <iostream>
using namespace std;
class CA
{
public:
CA(){cout<<"This is the constructor of CA"<<endl;}
~CA(){cout<<"This is the destructor of CA"<<endl;}
};
class CB
{
CA a;//只知道这里是类的组合
public:
CB(){cout<<"This is the constructor of CB"<<endl;}
~CB(){cout<<"This is the constructor of CB"<<endl;}
};
void fun(int n)
{
static CA a;//这里不清楚为啥定义静态
CB b;
cout<<"n="<<n<<endl;
}
void main()
{
fun(10);
fun(20);
CA *A;//这里不明白
CB *pb=new CB;//这里也是
delete pb;
}
只有本站会员才能查看附件,请 登录
[ 本帖最后由 大剑 于 2012-2-18 11:55 编辑 ]