D
Daniel Heiserer
Hi,
I got the following compiling/linking error, but I have no
clue what it is about.
Can anybody help me?
thanks, daniel
/tmp/ccVdAhtt.o(.gnu.linkonce.t._ZN1AC2Ev+0x8): undefined reference to
`vtable for A'
/tmp/ccVdAhtt.o: In function `A::~A [not-in-charge]()':
/tmp/ccVdAhtt.o(.gnu.linkonce.t._ZN1AD2Ev+0x8): undefined reference to
`vtable for A'
/tmp/ccVdAhtt.o(.gnu.linkonce.d._ZTI1B+0x10): undefined reference to
`typeinfo for A'
collect2: ld returned 1 exit status
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
class A{
public:
A(){;};
~A(){;};
virtual int doit();
};
class B:A{
int b;
public:
B(){b=-1;};
B(int x){b=x;};
int doit(){return b;};
};
using namespace std;
int main(){
/*
map<int,class B> Bs;
for (int x=0;x<10;x++){
Bs[x]=B(x*x);
}
for (map<int,B>::iterator IT=Bs.begin();IT!=Bs.end();IT++){
fprintf(stdout,"Bs[%d]=%d\n",IT->first,IT->second.doit());
}
*/
class B Bs1;
Bs1=B(23);
fprintf(stdout,"Bs[%d]=%d\n",23,Bs1.doit());
return 0;
}
-- thanks, daniel
I got the following compiling/linking error, but I have no
clue what it is about.
Can anybody help me?
thanks, daniel
/tmp/ccVdAhtt.o: In function `A::A[not-in-charge]()':g++ inheritance.cc
/tmp/ccVdAhtt.o(.gnu.linkonce.t._ZN1AC2Ev+0x8): undefined reference to
`vtable for A'
/tmp/ccVdAhtt.o: In function `A::~A [not-in-charge]()':
/tmp/ccVdAhtt.o(.gnu.linkonce.t._ZN1AD2Ev+0x8): undefined reference to
`vtable for A'
/tmp/ccVdAhtt.o(.gnu.linkonce.d._ZTI1B+0x10): undefined reference to
`typeinfo for A'
collect2: ld returned 1 exit status
g++ (GCC) 3.2.2g++ --version
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
#include <map>cat inheritance.cc
class A{
public:
A(){;};
~A(){;};
virtual int doit();
};
class B:A{
int b;
public:
B(){b=-1;};
B(int x){b=x;};
int doit(){return b;};
};
using namespace std;
int main(){
/*
map<int,class B> Bs;
for (int x=0;x<10;x++){
Bs[x]=B(x*x);
}
for (map<int,B>::iterator IT=Bs.begin();IT!=Bs.end();IT++){
fprintf(stdout,"Bs[%d]=%d\n",IT->first,IT->second.doit());
}
*/
class B Bs1;
Bs1=B(23);
fprintf(stdout,"Bs[%d]=%d\n",23,Bs1.doit());
return 0;
}
-- thanks, daniel