i know that you can not initialize the member variable(other than static const) inside the class directly without using constructor.
but just wanted to know what is the reason behind this. below is the code snippet
if any body could help
class a
{
int c=5;
// giving error error C2864: 'a::c' : only static const integral data members can be
// initialized within a class
int b;
public:
a():c(1),b(2){}
void h()
{
printf("%d,%d",c,b);
}
};
int main()
{
a l;
l.h();
getchar();
}