Reputation: 59
class CRA_Account {
int tax[4];
double refund[4];
int SIN;
public:
CRA_Account();
}
CRA_Account::CRA_Account() {
SIN = 0;
tax[4] = { 0 };
refund[4] = { 0 };
}
When I create a object in main it'll set the SIN to 0 but won't do the same to the arrays. Can someone help why?
Upvotes: 2
Views: 54
Reputation: 20264
tax[4] = { 0 };
is wrong at many levels..
One way to initlizie your class:
CRA_Account::CRA_Account():
tax{0,0,0,0},
refund{0,0,0,0},
SIN{0}{
}
Try to have a look at std::array
Upvotes: 2