G
Geiger Ho
Hi all,
Consider:
a.hh
====
struct A {
mytype_t attr1,
mytype_t attr2,
int attr3,
int attr4,
// some methods below
}
a.cc
====
extern const A DEFAULT_A = {attr1, attr2, attr3, attr4};
G++ compile with the following error:
'DEFAULT_A' must be initialized by constructor, not by `{...}'
How can I correct this?
Is it:
extern const A DEFAULT_A = *(new A(attr1, attr2, attr3, attr4));
And why it can't be that like C? I am just switched from C to C++, not very
familiar with C++.
Thanks in advance.
Regards,
Consider:
a.hh
====
struct A {
mytype_t attr1,
mytype_t attr2,
int attr3,
int attr4,
// some methods below
}
a.cc
====
extern const A DEFAULT_A = {attr1, attr2, attr3, attr4};
G++ compile with the following error:
'DEFAULT_A' must be initialized by constructor, not by `{...}'
How can I correct this?
Is it:
extern const A DEFAULT_A = *(new A(attr1, attr2, attr3, attr4));
And why it can't be that like C? I am just switched from C to C++, not very
familiar with C++.
Thanks in advance.
Regards,