© 2012 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies
« NS2  Projects »

Home Lab Exercise Object Oriented Programming Lab Exercise Programs CPP Program To Implement Virtual Base Classes▼


CPP Program To Implement Virtual Base Classes

Alogarithm steps:

  1. Start the program
  2. Create the class and declare the data members and data member functions
  3. We can create the virtual function also in the class
  4. Create the object for the class using array
  5. Call the function using the array object
  6. Compile and run the program

CPP Program To Implement Virtual Base Classes

#include template class MyClass { T value1, value2; public: MyClass (T first, T second){ value1=first; value2=second; } T getmax () { T retval; retval = value1>value2 ? value1 : value2; return retval; } }; int main () { MyClass myobject (10, 5); cout << myobject.getmax(); return 0; }

SAMPLE INPUT AND OUTPUT:
10

5

10

 
SLogix Student Projects

⇓ Student Projects ⇓
⇑ Student Projects ⇑
bottom