class "bankdeposit" has no member "show"
Here is the code:
#include <iostream>
using namespace std;
class bankdeposit
{
int principal, years;
float interest, returnvalue;
public:
bankdeposit(){};
bankdeposit(int p, int y, float r); // can be 2.00
bankdeposit(int p, int y, int r); // can be 2.
};
bankdeposit::bankdeposit(int p, int y, float r)
{
principal = p;
years = y;
interest = r;
returnvalue = principal;
for (int i = 0; i < y; i )
{
returnvalue = returnvalue * (1 r);
}
};
bankdeposit::bankdeposit(int p, int y, int r)
{
principal = p;
years = y;
interest = float(r) / 100;
returnvalue = principal;
for (int i = 0; i < y; i )
{
returnvalue = returnvalue * (1 r);
}
void show();
};
void bankdeposit::show(){
}
int main()
{
return 0;
}
CodePudding user response:
Inside the bankdeposit(int, int, int)
constructor, the expression void show();
is in the wrong place. It needs to be inside the bankdeposit
class declaration instead:
class bankdeposit
{
...
public:
...
void show(); // <-- move to here
};
bankdeposit::bankdeposit(int p, int y, int r)
{
...
// void show(); // <-- remove from here
};
On a site note, your default bankdeposit()
constructor is not initializing any of the class data members, so their values will be indeterminate. Either remove that constructor, or give the data members default values.