programming-examples/c++/Overview/CPP Program To Implement Virtual Base Classes.cpp

44 lines
725 B
C++
Raw Normal View History

2019-11-18 14:44:36 +01:00
// Start the program
// Create the class and declare the data members and data member functions
// We can create the virtual function also in the class
// Create the object for the class using array
// Call the function using the array object
// Compile and run the program
#include <iostream.h>
template <class T>
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 <int> myobject (10, 5);
cout << myobject.getmax();
return 0;
}