得出一个班...... [英] deriving a class...

查看:86
本文介绍了得出一个班......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过推导我的班级来阻止人们吗?

我的意思是我不希望我的班级成为基地......

我可以做吗?那个?

解决方案

Shraddha写道:


我可以阻止人们通过推导我的班级?

我的意思是我不希望我的班级成为基础班......

我可以这样做吗?



是的。请参阅常见问题解答。


V

-

请在通过电子邮件回复时删除资金'A'

我没有回复最热门的回复,请不要问


6月19日上午11点10分,Shraddha< ; shraddhajosh ... @ gmail.comwrote:


我可以通过派生班来阻止人们吗?

我的意思是我不是希望我的班级成为一个基类...

我可以这样做吗?



是的,你可以但是你必须对你的班级'

构造和继承做一些调整。


类可用;


类Usable_lock {

朋友类可用;

私人:

Usable_lock(){}

Usable_lock(const Usable_lock&){}

};


类可用:public virtual Usable_lock {

// ...

public:

Usable();

可用( char *);

// ...

};


可用a;


class DD:public Usable {};


DD dd; //错误:DD :: DD()无法访问

// Usable_lock :: Usable_lock():私有成员


你可以查看更多关于它的信息
http://www.research .att.com / ~bs / bs_f ... #no-derivation


问候,

Sarath
http://sarathc.wordpress.com/


" Shraddha" < sh ************* @ gmail.comwrote in message

news:11 ***************** ****@o11g2000prd.googlegro ups.com ...


我可以通过派生班来阻止人们吗?

我的意思是我我不希望我的班级成为基地......

我可以这样做吗?



3种方式,如常见问题所示:
http://www.parashift.com/c++-faq-lit...html#faq-23.11


Can I stop people by deriving my class?
I mean I don''t want my class to be as a base class...
Can I do that?

解决方案

Shraddha wrote:

Can I stop people by deriving my class?
I mean I don''t want my class to be as a base class...
Can I do that?

Yes. See the FAQ.

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


On Jun 19, 11:10 am, Shraddha <shraddhajosh...@gmail.comwrote:

Can I stop people by deriving my class?
I mean I don''t want my class to be as a base class...
Can I do that?

Yes you can but you have to do some tweaks with your class''s
construction and with inheritance.

class Usable;

class Usable_lock {
friend class Usable;
private:
Usable_lock() {}
Usable_lock(const Usable_lock&) {}
};

class Usable : public virtual Usable_lock {
// ...
public:
Usable();
Usable(char*);
// ...
};

Usable a;

class DD : public Usable { };

DD dd; // error: DD::DD() cannot access
// Usable_lock::Usable_lock(): private member

You can check more about it at
http://www.research.att.com/~bs/bs_f...#no-derivation

Regards,
Sarath
http://sarathc.wordpress.com/


"Shraddha" <sh*************@gmail.comwrote in message
news:11*********************@o11g2000prd.googlegro ups.com...

Can I stop people by deriving my class?
I mean I don''t want my class to be as a base class...
Can I do that?

3 ways, shown in the FAQ:
http://www.parashift.com/c++-faq-lit...html#faq-23.11


这篇关于得出一个班......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆