Practical 10
Practical 10
Write C++ Program with base class convert declares two variables, val1 and val2, which hold
the initial
and converted values, respectively. It also defines the functions getinit( ) and getconv( ),
which return the
initial value and the converted value. These elements of convert are fixed and applicable to
all derived
classes that will inherit convert. However, the function that will actually perform the
conversion, compute(
), is a pure virtual function that must be defined by the classes derived from convert. The
specific nature
of compute( ) will be determined by what type of conversion is taking place.
Programe:-
#include <iostream>
using namespace std;
// Base class 'Convert' which defines the common structure for conversion
class Convert {
protected:
double val1; // Initial value
double val2; // Converted value
public:
// Constructor to initialize val1 and val2
Convert(double initValue = 0) : val1(initValue), val2(0) {}
int main() {
double value;
return 0;
}