Virtual Constructor is possible in c++?

7 views
Skip to first unread message

Manika vasakam

unread,
May 12, 2005, 8:43:47 AM5/12/05
to CPPF...@googlegroups.com
if it is possible to achive virtual constructor, how?
plz.explain it with a code.

Regards
Manikam

Sriramkumar

unread,
May 17, 2005, 2:39:56 AM5/17/05
to CppF...@googlegroups.com
I dont think, there is something called virtual constructor in c++.
But you can simulate one if u need.

Juz chk this link
http://www.parashift.com/c++-faq-lite/virtual-functions.html
read ques 20.8

But i dont understand y u want to use virtual constructors. Can u give
me a scenario wherein u require virtual constructors.

Rahul Agarwal

unread,
May 17, 2005, 4:49:34 AM5/17/05
to CppF...@googlegroups.com
I wanna to know how the virtual keyword works
when we are saying that some class is inherited virtually
regards
Rahul Agarwal

Venkatesh Raja

unread,
May 17, 2005, 6:01:30 AM5/17/05
to CppF...@googlegroups.com

Check

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_virtual_base_classes.asp

You will get a detailed explanation.

Regards,
Venkat.
--

Regards,

Venkatesan P.R,
India.

------------------------------------------------------

Rahul Agarwal

unread,
May 17, 2005, 6:34:31 AM5/17/05
to CppF...@googlegroups.com
thanks
Venkatesan P.R,
India.


thats was the why we sud use virtual
i wanna to know how virtual will work
like
virtual uses a vtable and vptr mecanism
and it makes sense why some private virtual function will become accessible if same name is described virtual in base calss.
now when i am trying to simulate the macanism of virtual class
i m unable to simulate in such manner
.
 
--
Rahul Agarwal
(Software Developer)
Roy e solution
Delhi

Venkatesh Raja

unread,
May 17, 2005, 6:39:07 AM5/17/05
to CppF...@googlegroups.com

Rahul Agarwal

unread,
Jun 10, 2005, 6:15:02 AM6/10/05
to CppF...@googlegroups.com

> > Dear All.
> >
> > As far as i know that Then memeory is divided into the three segements
> >
> > 1. Heap;
> > 2. Stack;
> > 3. Data segmnet;
>
> That may be true in some implementations, but none of these are C
> terms.  In some implementations, malloc() and friends allocate memory
> from the "heap", local variables are on the "stack", and static and
> global variables are in the "data segment" -- but others may do things
> differently.
>
hi as u r writing that static and global will be in data segment , data segment is the part which is copied if an application is all ready in memory .
eg. if internate exploreer is allready open and we have clicked it once more a new code copy will not be there only the data segment part will be cpoied in memory and same codesegment will be used .
is it correct? it is .

now
i have program a application in which i have use a global static variable.
if the data segment is holding the static and global variables so that segment should be copied to other segment (as a new instance of that process play) but what is happening that global static variable is incrementing for the all three instance of that process are running.

Reply all
Reply to author
Forward
0 new messages