I'm getting both of following errors: "undefined reference to `Vessel::Vessel()' " and: "Id returned 1 exit status" but nothing shows up. How do I fix it? I tried everything but I can't come up with a solution.
It can be seen that the problem is in merging in classes or references but I can't figure out what exactly
Here is the code of the whole program:
#include<iostream>
#include<string>
using namespace std;
class Vessel{
protected:
string registration;
int power;
public:
Vessel();
Vessel(string r, int power){
r=registration;
power=power;
};
string set_registration(string put){
registration=put;
}
string get_registration(){
return registration;
}
double set_power(double set){
power=set;
}
double get_power(){
return power;
}
virtual void print()=0;
};
class Speedboat : public Vessel{
private:
int speed;
public:
set_speed(int s){
speed=s;
}
get_speed(){
return speed;
}
void print(){
cout<<get_registration()<<" "<<get_power()<<" "<<get_speed();
}
};
class Ferry : public Vessel{
private:
int capacity;
};
int main(){
Vessel * ptr;
Speedboat obj1;
ptr=&obj1;
obj1.set_power(5.2);
obj1.set_registration("ZG5212");
ptr->print();
}