I have a class with a static method that looks something like this:
class X {
static float getFloat(MyBase& obj) {
return obj.value();
}
};
I call it with an instance of MyDerived, which subclasses MyBase:
MyDerived d;
float f = X::getFloat(d);
If I link the obj file containing X to my executable, everything works as expected. If I expect to get 3.14, I get it.
If I create a .lib containing an X.obj file and a link in .lib, it breaks. When I call getFloat (), it returns -1. # IND00 . Is this some kind of sentinel value that should tell me what's wrong here?
Is there anything else when you directly link in lib and not obj?
I do not get any warnings or compiler errors.
Edit:
Visual Studio 2005 Windows XP Pro SP3. , , value() value2() . .
# 2:
, , , value(). () . , vtable . , , , - .
! ( )
, (ODR), , . - Visual ++, . /d1reportSingleClassLayout .
MyBase MyDerived , . , #ifdef, #define , (). , , , ?
, , - . .