C++中继承这边显示未初始化的内存是为什么呢?想了好久没想明白

#include
#include
#include
using namespace std;

class Bank
{
public:
void set(double a,int b, double c, double d)
{
interest = a; year = b; money = c; rates = d;
}
Bank( double c, double d)
{
money = c;
rates = d;
}
void Cal_Interest()
{
interest = year * money * rates;
}
protected:
double interest, money, rates;
int year;
};
class ConstructionBank:public Bank
{
public:
ConstructionBank(double b, double c, double d,double e) :Bank( c, d)
{
year = b;
Cdayrates = e;
}
void Cal_Interest()
{
double interest1;
interest1 = int(year) * money * rates + (year - int(year)) * money * Cdayrates;
}
private:
double year, Cdayrates;
};
class XMBank :public Bank
{
public:
XMBank(double b, double c, double d, double f) :Bank(c, d)
{
year = b;
XMdayrates = f;
}
void Cal_interest()
{
double interest2;
interest2 = int(year) * money * rates + (year - int(year)) * money * XMdayrates;
}
private:
double year, XMdayrates;
};
int main()
{
ConstructionBank(5.216,50000,0.035,0.0001);
XMBank(5.216, 50000, 0.035, 0.00015);
return interest1;
return interest2;
}

img

ConstructionBank cb(5.216,50000,0.035,0.0001);
XMBank xb(5.216, 50000, 0.035, 0.00015);
你要定义类变量名啊,怎么是类名直接带参数呢
============
void Cal_Interest()
{
double interest1;
interest1 = int(year) * money * rates + (year - int(year)) * money * Cdayrates;
}
这是毫无意义的函数啊。计算interest1的目的是啥呢?你应该将它return啊
double Cal_Interest()
{
return int(year) * money * rates + (year - int(year)) * money * Cdayrates; //这样就行了
}