P
Pedro Miguel Carvalho
Greetings.
I have a class that I would like to initialize with a literal array but it
is not accepted by the compiler. It works if I use a array variable but not
a literal array. Can someone shed some light on this.
class test {
public:
test( const float T[10] ) {
}
};
int main( void ) {
float V[10] = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0};
test T1 = V; //
OK
test T2 = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0}; // Syntax error
test T3( {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0} ); // Syntax error
}
I have a class that I would like to initialize with a literal array but it
is not accepted by the compiler. It works if I use a array variable but not
a literal array. Can someone shed some light on this.
class test {
public:
test( const float T[10] ) {
}
};
int main( void ) {
float V[10] = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0};
test T1 = V; //
OK
test T2 = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0}; // Syntax error
test T3( {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0} ); // Syntax error
}