By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 833 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

dynamic binding

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.