Question: Need help fixing errors in my code #include // using namespace std; // class Object //Abstract class in C++ { public : void show ()

Need help fixing errors in my code

#include // using namespace std; // class Object //Abstract class in C++ { public : void show () = 0; //pure virtual function }; //Inheritance class ArithmeticAdd : public Object { int res; public: void add (int a, int b) { res = a + b ; } void add (int a, int b, int c) // Function overloading - Static Binding { res = a + b + c; } void show () { cout << "Result = " << res; } }; // class Complex : public Object { int real; int img; public : Complex Add (Complex C1, Complex2) { real = C1.real + C2.real; img = C1.img + C2.img; return this; } void show () { cout << real << " + " << img << "i" <> (istream &, Complex &); // Friend functions and operator overloading }; // istream & operator >> (istream & in, Complex & c) { in >> c.real >> c.img; return in; } // int main () { Object o [2]; ArithmeticAdd a; a.add (2,6); o [0] = &a; o [0].show (); // Dynamic dispatch - run time polymorphisms a.add (9,11,23); o [0].show (); Complex C1, C2, C3, C4; cin >> C1; cin >> C2; C4 = C3.Add (C1, C2); // Message passing o [1] = & C4; o [1].show (); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!