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 16 3758
plmanikandan wrote: Can anybody explain me about virtual constructor?
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,
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**********@gm ail.com: 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 "constructo r" (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?
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? pl**********@gm ail.com wrote: 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
When you make a function virtual that function is binded after the
object has been created.
But if you take a constructor it is called at the time of creation of
the object.
Constructor cannot be binded after the object is created.
dude how can the constructors can be virtual ??
here is the reference frm bjarne stroustrup's tech. faq: http://public.research.att.com/~bs/b...l#virtual-ctor
Alf P. Steinbach wrote: * pl**********@gm ail.com: 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 "constructo r" (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?
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?
* al pacino: [top-posting] [quoting extranous material] [quoting signature]
Please don't top-post. Please don't quote irrelevant stuff. See the
FAQ and Shiva's monthly "Welcome"-posting in this group.
--
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?
"Alf P. Steinbach" <al***@start.no > wrote in message
news:47******** ****@individual .net... * pl**********@gm ail.com: 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.
Actually, it's probably because he's Norweigian and English is not his
primary language. 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 "constructo r" (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.
No. From the FAQ 20.8 in part:
An idiom that allows you to do something that C++ doesn't directly support. Can anybody explain me about virtual constructor?
Yes, see the FAQ.
Yes, see the FAQ 20.8 You can't have a virtual constructor, but you can
have something that mimics what a virtual constructor would do.
Again, FAQ 20.8 in a bigger part:
You can get the effect of a virtual constructor by a virtual clone() member
function (for copy constructing), or a virtual create() member function (for
the default constructor).
Here is the link to the FAQ 20.8: http://www.parashift.com/c++-faq-lit....html#faq-20.8
al pacino wrote: dude how can the constructors can be virtual ??
Easy. What is commonly called a "virtual constructor" just happens not to be
a constructor (like the Holy Roman Empire was neither roman nor holy and it
is debatable whether it was an empire).
here is the reference frm bjarne stroustrup's tech. faq: http://public.research.att.com/~bs/b...l#virtual-ctor
Did you read what he wrote there? I quote from *that* page:
Techniques for using an indirection when you ask to create an object
are often referred to as "Virtual constructors". For example, see
TC++PL3 15.6.2.
Alf P. Steinbach wrote: * pl**********@gm ail.com:
[snip]
And please, don't top-post.
Best
Kai-Uwe Bux
* Jim Langston: "Alf P. Steinbach" <al***@start.no > wrote in message news:47******** ****@individual .net... * pl**********@gm ail.com: 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.
Actually, it's probably because he's Norweigian and English is not his primary language.
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 "constructo r" (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.
No. From the FAQ 20.8 in part:
An idiom that allows you to do something that C++ doesn't directly support.
Can anybody explain me about virtual constructor? Yes, see the FAQ.
Yes, see the FAQ 20.8 You can't have a virtual constructor, but you can have something that mimics what a virtual constructor would do.
Again, FAQ 20.8 in a bigger part: You can get the effect of a virtual constructor by a virtual clone() member function (for copy constructing), or a virtual create() member function (for the default constructor).
Here is the link to the FAQ 20.8: http://www.parashift.com/c++-faq-lit....html#faq-20.8
I'm not sure what point (if any) you were trying to make? Confuse the
newbie, and remove his or her learning experience in searching the FAQ?
Look how smart I am, I managed to find it in the FAQ?
Anyway, your unqualified "no" above is incorrect. C++ does indeed
support all that's needed to implement what's known as a virtual
constructor, including virtual member functions and function result
covariance. Note that this does not contradict the FAQ's statement.
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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lefevre |
last post by:
Hello
I recently had troubles with a class inheritance hierarchy.
I solved it, but it didn't satisfied me.
I found the solution using this forum :)
Actualy i found the following message (with no responces associated) :
|
by: Stub |
last post by:
Please answer my questions below - thanks!
1. Why "Derived constructor" is called but "Derived destructor" not in Case
1 since object B is new'ed from Derived class?
2. Why "Derived destructor" is called in Case 2 since only ~base() becomes
"virtual" and ~Derived() is still non-virtual?
3. Does Case 3 show that we don't need any virtual destructor to make
~Derived() called?
4. Is "virtual destructor" needed only for Case 2?
|
by: Thomas Matthews |
last post by:
Hi,
Is placing the keyword "virtual" in front of a constructor
allowed as in the sample below?
class TTable
{
virtual TTable();
};
My compiler, Borland Builder 5.2, has system libraries
|
by: ccs |
last post by:
In Meyers' book he gave an example of "virtual copy constructor", which is
quite different to an "ordinary" copy constructor by:
1. it returns a pointer to an object instead of a reference.
2. it have empty argument list.
3. it has "virtual" keyword in front of it.
My questions are:
1. How could "virtual" be used in front of a constructor even though it's a
"copy constructor"?
2. Can an "ordinary" copy constructor be "virtual?
|
by: Ruben Van Havermaet |
last post by:
Hi,
I have a problem using member functions in derived classes that
override virtual member functions of base classes.
The following pieces of (simplified) code don't work. Can anybody give
me some hints on what might be wrong?
// BEGIN OF SAMPLE CODE
class Strategy
| |
by: Stefan Nikolaus |
last post by:
Hello,
I've run into problems with defining a template, which inherits from a
base template and the usage of virtual methods in those. I want to
initialize a member variable depending on which template is created and
I tried to define a virtual method, that's called from the base
template ctor. Here's my example code:
#include <iostream>
|
by: Klaas Vantournhout |
last post by:
Hi,
Recently I obtained a problem with virtual inheritance when implementing
it in multiple files. To present the problem I have included at the
bottom of this post the code of the 4 files. I show results with the
gnu compiler but i have the same results with the intel compiler.
file1.cpp compiles without a problem, the problem occurs when compiling
file2.cpp. It complains about not finding the constructor of the class
base.
|
by: Bart Simpson |
last post by:
Can anyone explain the concept of "slicing" with respect to the "virtual
constructor" idiom as explain at parashift ?
From parashift:
class Shape {
public:
virtual ~Shape() { } // A virtual destructor
|
by: Jess |
last post by:
Hello,
If I have a class that has virtual but non-pure declarations, like
class A{
virtual void f();
};
Then is A still an abstract class? Do I have to have "virtual void
f() = 0;" instead? I think declaring a function as "=0" is the same
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |