i have two question
1.If i have this two classes
so whats wrong with this code?? and how to fix it (simple solution) ??Code:class Vehicle { public: virtual int weight() const; //.... }; class Automobile { public: int weight() const; //.... }; // this function is global int heavy(Vehicle v) { return v.weight() > 12000; } // main Automobile a; if (heavy(a)) { //.. }
2. if class Y inherits from class X then following assignment is illegal
Any example why allowing this kind of assignemnt would be an extremely bad idea?Code:X x; Y y; y = x;