/tmp/ccNvtehj.o: In function `tool::tool()':
tool.cpp:(.text+0xf): undefined reference to `vtable for tool'
/tmp/ccNvtehj.o: In function `tool::tool(tool const&)':
tool.cpp:(.text+0x3b): undefined reference to `vtable for tool'
/tmp/cc4j4M7t.o:(.rodata._ZTI4rock[typeinfo for rock]+0x10): undefined reference to `typeinfo for tool'
/tmp/cclhq2Zz.o:(.rodata._ZTI5paper[typeinfo for paper]+0x10): undefined reference to `typeinfo for tool'
/tmp/cceU2w5F.o:(.rodata._ZTI8scissors[typeinfo for scissors]+0x10): undefined reference to `typeinfo for tool'
collect2: ld returned 1 exit status
Here's my codes:
tool.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#ifndef TOOL_H
#define TOOL_H
class tool
{
protected:
int strength;
char type;
public:
tool();
tool(tool const &);
void set_strength(int);
virtualbool fight(tool *);
char get_type();
int get_strength();
};
#endif
Can anyone help me out with what exactly these errors mean and if at all possible, could I get a bit of guidance in fixing the errors. I'd be ever so grateful. :)
"undefined reference" means the compiler can't find the definition of a function. I think the function it complains about is the fight function but you should also define the set_strength function.