Write a c class base has two member functions add


Program 1: Write a C++ class Base has two member functions: //add constructor(s) if needed int f () {return x*25;} //x is a protected data member of Base class virtual int g() {return x *35; }

Program 2: Prepare a C++ class Derived that inherits from Base and has one member function: //add constructor(s) if needed int g() {return x*45;}

Program 3: Prepare a main function that creates two objects and large number of calls to each of the function: Base *b1 = new Base (...); Base *b2 = new Derived (...); int result; for (int i=0; i<10000; i="" result1="b1-">f(); } //piece 1 for (int j=0; j<10000; j="" result2="b2-">g(); } //piece 2

Program 4: Record the timing for running piece 1 and piece2 respectively. Compare the difference of the time required by the two. Describe the difference.

You need to implement this in C++ language. You need to provide the answer as soon as possible.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write a c class base has two member functions add
Reference No:- TGS0956272

Expected delivery within 24 Hours