我可以通过推导我的班级来阻止人们吗? 我的意思是我不希望我的班级成为基地...... 我可以做吗?那个?
解决方案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
更多推荐
得出一个班......
发布评论