-gc类细节
vc.net
1:gc类对像不能在stack上面建立.只能用new在head上面建立对像.
__gc class Sample
{
private:
double number;
public:
Sample( double num): number(num){};
};
Sample* s = new Sample(3.2);//只能这样create a instance.
2:gc类的继承只能在mangaed class中派生出来.
3:single继承
__gc class A
{
protected:
int a;
};
__gc class B
{
protected:
int b;
};
__gc class Sample: public A, public B //it is wrong.
{
public:
Sample(int x, int y) : a(x), b(y) {}
};
4:不能用firend关键字,让别的类可以防问mangaed class 中的private 数据.
5:mangaed class 中的数据成员不能是 unmanaged class 对象.
6:不能执行一个复制构制函数
7:不能定义new ,& 操作符.
1:gc类对像不能在stack上面建立.只能用new在head上面建立对像.
__gc class Sample
{
private:
double number;
public:
Sample( double num): number(num){};
};
Sample* s = new Sample(3.2);//只能这样create a instance.
2:gc类的继承只能在mangaed class中派生出来.
3:single继承
__gc class A
{
protected:
int a;
};
__gc class B
{
protected:
int b;
};
__gc class Sample: public A, public B //it is wrong.
{
public:
Sample(int x, int y) : a(x), b(y) {}
};
4:不能用firend关键字,让别的类可以防问mangaed class 中的private 数据.
5:mangaed class 中的数据成员不能是 unmanaged class 对象.
6:不能执行一个复制构制函数
7:不能定义new ,& 操作符.