Good day!
I have started a little inheritance on my simple class that takes the addition function of two numbers on the other class but the sum is always zero even if it is not supposed to be. Here is my code so far:
#include<iostream>
using namespace std;
class Addition
{
public:
float num1, num2, sum;
Addition(){};
~Addition(){};
};
class Subtraction: public Addition
{
public:
void ExecuteAddtion()
{
sum=num1 + num2;
}
Subtraction(){};
~Subtraction(){};
};
Addition Addme;
Subtraction SubtractMe;
int main()
{
cout<<"Enter first number: ";
cin>>Addme.num1;
cout<<"Enter second number: ";
cin>>Addme.num2;
SubtractMe.ExecuteAddtion();
cout<<"The sum of "<<Addme.num1<<" and "<<Addme.num2<<" is "<<Addme.sum<<endl;
system("pause");
return 0;
}
Thank you for helping!