class sum
{
protected:
int num, rang;
public:
sum(){
cin >> num;
cin >> rang;
}
sum(int num, int rang){
int n = 10;
int sum = 0;
for(int i = 0; i < rang; i++){
num += n;
sum += num;
}
num = sum;
cout << num << '\n';
}
};
int main()
{
sum obj;
return 0;
}
When I call second costructor (overload constructor), it should print sum, but it prints nothing, I think it even isn't calling by previous censtructor, why?
Aucun commentaire:
Enregistrer un commentaire