虚拟构造函数 [英] Virtual constructor

查看:141
本文介绍了虚拟构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我怀疑reg虚拟构造函数

什么是虚构造函数?

c ++是否支持虚拟构造函数?

任何人都可以向我解释虚拟构造函数吗?

问候,

Mani

Hi,
I have doubts reg virtual constructor
what is virtual constructor?
Is c++ supports virtual constructor?
Can anybody explain me about virtual constructor?
Regards,
Mani

推荐答案

plmanikandan写道:
plmanikandan wrote:
任何人都可以向我解释虚拟构造函数吗?
Can anybody explain me about virtual constructor?




Raw C ++无法调用虚构造函数(因为构造函数不是
真的是一个函数)。可能有一些常见的设计模式。


你如何使用谷歌来调查这个主题并在这里报告?


-

Phlip
http://www.greencheese.org / ZeekLand < - 不是博客!!!



Raw C++ cannot call a constructor virtually (because a constructor is not
really a function). There''s probably some common design pattern.

How about you use Google to survey the topic and report back here?

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!


hii,

没有像虚拟构造函数这样的东西c ++,它没有使得

感觉。

a构造函数是一个函数(可以明确定义,编译器调用

当一个对象时创建了一个

类。)


当一个

派生类对象时,需要一个虚拟析构函数来解决歧义

是通过基类指针删除的(''派生类''是'A''基础

类'')因为编译器

必须决定删除派生对象或基础对象的内容。

因此声明析构函数虚拟解决了问题。


虚拟构造函数的概念对我来说没有意义。

如果在这里不合适,请纠正我。

谢谢

hii,
there is no such thing as virtual constructor in c++, it doesn''t make
sense.
a constructor IS a function(can be defined explicitly , compiler calls
it when an object of a
class is CREATED.)

A virtual destructor is required to resolve the ambiguity,when a
derived class object
is deleted via a base class pointer(a ''derived class'' IS A ''base
class'') since compiler
has to decide what to delete derived object or base object.
thus declareing the destructor virtual resolves the ambugity.

concept of virtual constructor doesnt'' make sense to me.
please correct me if nething is out of place here.
thanks


* pl ***** *****@gmail.com

我怀疑reg虚拟构造函数


注意:疑问意味着你不确定某些事情是否属实,或者

一个人是否真实或可靠。


你的上述用法毫无意义且很可能由于字典不好。


什么是虚构造函数?


请参阅常见问题解答。使用常见问题解答的谷歌搜索(它位于

常见问题解答的主页上)来查找短语虚拟构造函数。在FAQ中。除了

之外的意思,它只有一个外围的连接词

" virtual"和构造函数 (它更像是一个随机短语,对于

一些历史原因已经获得了一定的意义),常见问题解答也是b / b $ b $讨论另一个更自然的含义;在常见问题解答中搜索短语

初始化期间的动态绑定找到那个讨论。


c ++是否支持虚拟构造函数?


是的。


有人能解释一下虚构造函数吗?

I have doubts reg virtual constructor
Note: "doubt" means you are unsure whether something is true or not, or
whether a person is truthful or reliable, or not.

Your usage above is meaningless and probably due to a bad dictionary.

what is virtual constructor?
See the FAQ. Use the FAQ''s Google search (it''s on the main page of the
FAQ) to find the phrase "virtual constructor" in the FAQ. Apart from
that meaning, which has only a peripheral connection to the words
"virtual" and "constructor" (it''s more like a random phrase that for
some historical reason has acquired a given meaning), the FAQ also
discusses another more natural meaning; search the FAQ for the phrase
"Dynamic Binding During Initialization" to find that discussion.

Is c++ supports virtual constructor?
Yes.

Can anybody explain me about virtual constructor?




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


Hth。,


- Alf


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么这么糟糕?

答:热门发布。

问:usenet和电子邮件中最烦人的事情是什么?



Yes, see the FAQ.

Hth.,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


这篇关于虚拟构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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