得出一个班......

编程入门 行业动态 更新时间:2024-10-28 07:26:25
本文介绍了得出一个班......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我可以通过推导我的班级来阻止人们吗? 我的意思是我不希望我的班级成为基地...... 我可以做吗?那个?

解决方案

Shraddha写道:

我可以阻止人们通过推导我的班级? 我的意思是我不希望我的班级成为基础班...... 我可以这样做吗?

是的。请参阅常见问题解答。 V - 请在通过电子邮件回复时删除资金'A' 我没有回复最热门的回复,请不要问

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

我可以通过派生班来阻止人们吗? 我的意思是我不是希望我的班级成为一个基类... 我可以这样做吗?

是的,你可以但是你必须对你的班级' 构造和继承做一些调整。 类可用; 类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 / ~bs / bs_f ... #no-derivation 问候, Sarath sarathc.wordpress/

" Shraddha" < sh ************* @ gmailwrote in message news:11 ***************** ****@o11g2000prd.googlegro ups ...

我可以通过派生班来阻止人们吗? 我的意思是我我不希望我的班级成为基地...... 我可以这样做吗?

3种方式,如常见问题所示: www.parashift/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...@gmailwrote:

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 www.research.att/~bs/bs_f...#no-derivation Regards, Sarath sarathc.wordpress/

"Shraddha" <sh*************@gmailwrote in message news:11*********************@o11g2000prd.googlegro ups...

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: www.parashift/c++-faq-lit...html#faq-23.11

更多推荐

得出一个班......

本文发布于:2023-05-25 10:59:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/226677.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!