Can any one let me know on what is the advantage of default constructor over assingment operator.
take an example.
what is the advantage of second over first?
The second is valid C++ code.
The first will not compile.
Disch thanks for the reply!
what if i change to
I know the answer the second wont compile either! Thanks!
You simply can't make an in-class definition this will not obey the c++ linker rules.
C++ requires that every object has a unique definition. That rule would be broken if C++ allowed in-class definition of entities that needed to be stored in memory as objects.
So you can initialize those members in constructors only, unless it is a static const of integral or enumeration type.