I am just trying to get my code to compile. I've done this before and it looks exactly the same in its methods, but for some reason, when I'm trying to run it using different methods, it won't compile. The error is in the cpp file. Any help would be great! Thanks
Error is:
/tmp/ccexQEF7.o: In function `Animal::Animal(std::string)':
Animal.cpp:(.text+0x11): undefined reference to `vtable for Animal'
collect2: error: ld returned 1 exit status
This is my header file:
#include <iostream>
#ifndef ANIMAL_H
#define ANIMAL_H
class Animal
{
public:
Animal(std::string name);
std::string get_name();
virtual int get_weight();
virtual int get_age();
protected:
std::string animalName;
};
class Cat: public Animal
{
public:
Cat(double weight, int age);
std::string get_name();
virtual int get_age();
virtual int get_weight();
protected:
std::string catType;
};
#endif
This is my cpp file:
#include <iostream>
#include "Animal.h"
using namespace std;
Animal::Animal(string name)
{
animalName = name;
};