|
-
Aug 18th, 2001, 05:14 AM
#1
Thread Starter
transcendental analytic
Delegation vs Inheritance
Some I asked say that superclass functions are instantiated once while obtaining access to base class variables via an extra addition (for the offset in different derivatives) while others say that it's compiler dependent? Or does the functions get instantiated per subclass?
The problem I'm not facing but took out of the blue, is 3 classes which are subclasses of 3 other superclasses. A, B and C are superclasses while AB, AC,BC are subclasses which derive 2 different classes each.
The objects will contain data that will obviously misaligned at least in one class:
aaaabbbbbb
aaaaccc
bbbbbbccc
Suppose a function in the base class B has to edit bbbbbb, in AB it occurs at offset=4 in BC it occurs at offset=0. What will the compiler do? Will it instanciate 2 functions, will a offset be passed with the function and then added to each variable? Will the pointer to the object not be passed but a pointer to the offset data passed? What happens with this pointer then?
The problem i'm facing is having a templitized baseclass which is quite rich of methods which i need to derive quite a lot, would it be smarter to use delegation instead, i'd rather not but I need to know how the compiler (I'm using MS VC++6) handles it.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|