469,142 Members | 1,136 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,142 developers. It's quick & easy.

dynamic binding

Hi there,

I want to learn how the compiler is implementing the dynamic binding. where
can i read about this subject (the hole process).

thanks.


Jul 22 '05 #1
2 3058
festiv wrote:
Hi there,

I want to learn how the compiler is implementing the dynamic binding. where
can i read about this subject (the hole process).


C++ uses static binding so it becomes rather difficult to describe how
it does dynamic binding. You can't say how something does a thing it
does not do :P

Objective-C is a language based on C that has dynamic binding. Maybe
you want to look into that language if you are really interested in how
it is done.

--
"I'm a war president. I make decisions here in the Oval Office
in foreign policy matters with war on my mind." - Bush

Jul 22 '05 #2
Noah Roberts wrote:
festiv wrote:

I want to learn how the compiler is implementing the dynamic binding.
where can i read about this subject (the hole process).


C++ uses static binding so it becomes rather difficult to describe how
it does dynamic binding. You can't say how something does a thing it
does not do :P


Noah,

How do you define "dynamic binding?" I've always understood the term to
mean something like "resolving a member function call at run time rather
than compile time." I would have said C++ supports dynamic binding with the
"virtual" keyword.

festiv,

If you want to know how your compiler implements virtual member functions,
then for a definitive answer you'd have to ask the people who made your
compiler. The C++ standard doesn't require any particular implementation,
although I suspect all real C++ compilers use some sort of "vtable" approach
(see link below).

One of my former professors has some lecture notes online that might
interest you. I think they'll give you an idea of what's probably happening
behind the scenes:

http://www.libertysoft.com/ggu/cis30...ymorphism.html

Unfortunately, I think his second-to-last code example has a couple of
typos. The Manager class' constructor should probably look like this:

Manager::Manager(EmployeeID const&id, StoreID const&store,
double payrate) : Employee(id, store, payrate, polys_)
{
}

or maybe

Manager::Manager(EmployeeID const&id, StoreID const&store,
double payrate) : Employee(id, store, payrate, &polys_)
{
}

depending on whether the Employee class' constructor takes a pointer to a
Polymorphics struct or a reference to a Polymorphics struct.

And the AssistantManager class' constructor should probably look something
like this:

AssistantManager::AssistantManager(EmployeeID const&id, StoreID
const&store, double payrate) : Employee(id, store, payrate, polys_)
{
}

or maybe

AssistantManager::AssistantManager(EmployeeID const&id, StoreID
const&store, double payrate) : Employee(id, store, payrate, &polys_)
{
}

--
Russell Hanneken
rg********@pobox.com
Remove the 'g' from my address to send me mail.
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by prashna | last post: by
9 posts views Thread by Gibby Koldenhof | last post: by
3 posts views Thread by compgeek.320 | last post: by
3 posts views Thread by Colin | last post: by
13 posts views Thread by Jess | last post: by
4 posts views Thread by aarklon | last post: by
26 posts views Thread by Aaron \Castironpi\ Brady | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.