R
ravinder thakur
hi all experts,
i have a structure with the constant memebers such as one given below:
typedef struct {
const int cbcode;
int cberror;
} xtsetplatestaterec;
now in my function i want to create a stack based object for the same:
void CreateObjectAndUseIt{
xtsetplatestaterec plate;
xtsetplatestaterec plate2 = {0 , 0};
}
now this function is giving the compilation errors while compiling on
vc++ 6.0 since the
cbcode memeber is a constant. the error is
error C2512: 'xtsetbleedvaluesrec' : no appropriate default constructor
available
error C2552: 'tmpsetplatestaterec' : non-aggregates cannot be
initialized with initializer list
can anybody plz explain me what could be done to create instances of
these objects on stack ???
strangly this code compiles in the c framework and not in the c++
framework.
is there some difference in the way interpertation of const members in
structures in c
and c++ language??? and if yes then is there any work around to the
problem other than removing the const from the strctures.
thanks
rt
i have a structure with the constant memebers such as one given below:
typedef struct {
const int cbcode;
int cberror;
} xtsetplatestaterec;
now in my function i want to create a stack based object for the same:
void CreateObjectAndUseIt{
xtsetplatestaterec plate;
xtsetplatestaterec plate2 = {0 , 0};
}
now this function is giving the compilation errors while compiling on
vc++ 6.0 since the
cbcode memeber is a constant. the error is
error C2512: 'xtsetbleedvaluesrec' : no appropriate default constructor
available
error C2552: 'tmpsetplatestaterec' : non-aggregates cannot be
initialized with initializer list
can anybody plz explain me what could be done to create instances of
these objects on stack ???
strangly this code compiles in the c framework and not in the c++
framework.
is there some difference in the way interpertation of const members in
structures in c
and c++ language??? and if yes then is there any work around to the
problem other than removing the const from the strctures.
thanks
rt