J
junw2000
I write a class as below:
class c1 {
public:
c1(): a(2), c[4]('\0') {} //LINE1
private:
int a;
char c[5];
}
But LINE1 can not pass compiling.
I modify it as:
class c1 {
public:
c1(): a(2){
c[4] = '\0'; //LINE1
}
private:
int a;
char c[5];
}
It works. Is there a better way to write the constructor? Thanks.
class c1 {
public:
c1(): a(2), c[4]('\0') {} //LINE1
private:
int a;
char c[5];
}
But LINE1 can not pass compiling.
I modify it as:
class c1 {
public:
c1(): a(2){
c[4] = '\0'; //LINE1
}
private:
int a;
char c[5];
}
It works. Is there a better way to write the constructor? Thanks.