I have two questions. I run the below code and it sets each array object variable to 20 ın GCC 6.3 version.
However, when I try the higher version of GCC, It gives an error.
Why is there this changing?
#include <iostream>
class A{
int a;
public:
A(int);
};
A::A(int init_val){
this -> a = init_val;
}
int main(){
A a[10](20);
}
Actually, I want to set an array which has more parameters for a constructor like that:
A(int, char);
A a[10](20, 'A');
The final version of the code is below. This gives an error in every version of gcc.
Is there any way to set an array object like that?
#include <iostream>
class A{
int a;
char b;
public:
A(int, char);
};
A::A(int init_val, char init_ch ){
this -> a = init_val;
this -> b = init_ch;
}
int main(){
A a[10](20, 'A');
}