Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 27th, 2004, 3:29 AM   #1
mehul
Newbie
 
Join Date: Oct 2004
Posts: 3
Rep Power: 0 mehul is on a distinguished road
when is the virtual table created?

will a virtual table created in the following scenario?
if created why?
if not created why?

code sample:

class base
{
virtual void print (void)
{
cout << "base"<<endl;
}
};

class derived
{
void print (void)
{
cout << "derived" << endl;
}
};

int main (int argc, char argv)
{
derived d;

return 0;
}
mehul is offline   Reply With Quote
Old Oct 27th, 2004, 3:48 AM   #2
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
that isnt a virtual table there its just a few classes :/
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Old Oct 27th, 2004, 4:56 AM   #3
mehul
Newbie
 
Join Date: Oct 2004
Posts: 3
Rep Power: 0 mehul is on a distinguished road
i dont think virtual table creations is linked with no. of classes defined.

mehul.
mehul is offline   Reply With Quote
Old Oct 28th, 2004, 6:11 AM   #4
mehul
Newbie
 
Join Date: Oct 2004
Posts: 3
Rep Power: 0 mehul is on a distinguished road
oh a big mistake. sorry.
now look at the following:

code sample:

class base
{
virtual void print (void)
{
cout << "base"<<endl;
}
};

class derived : public base
{
void print (void)
{
cout << "derived" << endl;
}
};

int main (int argc, char argv)
{
derived d;

return 0;
}

now the ques. is whether virtual table will be created?
how many?
one for base?
and one for derived?
there is no base class pointer scenario
even then virtual table will be created?
if yes why?

mehul.
mehul is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:13 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC