c++ - Why am I getting errors using virtuals? -


im trying create polymorphic classes using couple of examples have, followed them best , had kinda work around it, not quite sure why isn't compiling.

#include<string> #include<iostream> #include<vector> #include<memory> #include<ctime> using namespace std;  class vehicle { public:     string colour;     int wheels;     //deconstructor     virtual ~vehicle(){}     virtual void setcolour(string col) {}     virtual string getcolour() { return colour; }     virtual int getwheels() { return wheels; }     virtual void setwheels(int numwheels){};     vehicle(int numwheels, string col) : wheels(numwheels), colour(col){} };  class auto : public vehicle{ public:     auto(int numwheels, string col) : vehicle(numwheels, col){}     void setwheels(int numwheels){ wheels = numwheels; }     void setcolour(string col){ colour = col; }     int getwheels();     string getcolour(); };  class bike : public vehicle{ private:     string scol;     int iwheel; public:     bike(int numwheels, string col) : vehicle(numwheels, col){}     void setwheels(int numwheels){ wheels = numwheels; }     void setcolour(string col){ colour = col; }     int getwheels();     string getcolour(); };   int main(){     auto car1(4, "white");     cout << car1.getcolour() << endl;     bike bike1(2, "grey");     cout << bike1.getcolour() << endl; } 

im getting weird error, have final exam coming in 12 hours, , don't why c++ code won't compile.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -