Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   need help with undefined reference errors (http://www.velocityreviews.com/forums/t503633-need-help-with-undefined-reference-errors.html)

boyphp 05-02-2007 04:42 PM

need help with undefined reference errors
 
I'm getting the following undefined reference errors:

foo_test.o(.gnu.linkonce.t._ZN7CFooD1Ev+0x18): In function
`CFoo::~CFoo()':
: undefined reference to `vtable for CFoo'
foo_test.o(.gnu.linkonce.t._ZN7CFooC1Ev+0x19): In function
`CFoo::CFoo()':
: undefined reference to `CFoo::rmap'
foo_test.o(.gnu.linkonce.t._ZN7CFooC1Ev+0x30): In function
`CFoo::CFoo()':
: undefined reference to `vtable for CFoo'

The implementation of the concerned functions is given below. I'm
pretty sure it is reading the file. What exactly could be going wrong?
------------------------------------------------------------------------------------------------------------------
class CFoo : public CIFoo
{
public:
CFoo() : CIFoo( PID_FOO, rmap) {};

CFoo( const CFoo& c ) : CIFoo( PID_Foo, rmap )
{
}

~CFoo()
{
}
private:
char* rmap;
};


freak@fsfoundry.org 05-02-2007 05:41 PM

Re: need help with undefined reference errors
 
Without the full source code, I am guessing the base class `CIFoo' has
no virtual destructor.


Victor Bazarov 05-02-2007 06:14 PM

Re: need help with undefined reference errors
 
boyphp wrote:
> I'm getting the following undefined reference errors:
>
> foo_test.o(.gnu.linkonce.t._ZN7CFooD1Ev+0x18): In function
> `CFoo::~CFoo()':
>> undefined reference to `vtable for CFoo'

> foo_test.o(.gnu.linkonce.t._ZN7CFooC1Ev+0x19): In function
> `CFoo::CFoo()':
>> undefined reference to `CFoo::rmap'

> foo_test.o(.gnu.linkonce.t._ZN7CFooC1Ev+0x30): In function
> `CFoo::CFoo()':
>> undefined reference to `vtable for CFoo'

>
> The implementation of the concerned functions is given below. I'm
> pretty sure it is reading the file. What exactly could be going wrong?

[..]

Quoting the Standard:
"A virtual member function shall be declared pure _or_ defined
_or_ both."

That means you cannot declare a virtual function but not define it.
Also, it's possible that the base class of CFoo has pure d-tor...
The cod you posted does not have enough information in it.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask




All times are GMT. The time now is 06:52 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.