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 ,& 操作符.
博客围绕vc.net中的gc类展开,介绍了其使用限制。如gc类对象只能用new在堆上创建,继承只能在托管类中派生,不支持多重继承,不能用friend关键字访问私有数据,数据成员不能是非托管类对象,不能执行复制构造函数,也不能定义new和&操作符。
2571

被折叠的 条评论
为什么被折叠?



