C Structures Vs C++ Structures
1.structures in C don't have member functions
2.The defination of the structure in C is limited to within the module and cannot be initialized outside its scope.
Where as in C++ you can initialize the objects anywhere within the boundaries of the project.
3. In C++ structure label is typedeffed by default
Ex:
struct Mystruct
{
int i;
char c;
};
Mystruct Ms1; //illegal in C but legal in C++
struct Mystruct Ms2; //legal in both C and C++
typedef struct Urstruct
{
int I;
char C;
}US;
Urstruct Us1; //illegal in C but legal in C++
struct Urstruct Us2; //legal in both C and C++
US Us3; //legal in both C and C++
struct US Us4; //illegal in both C and C++
4. Size of empty structure is 0 in C but 1 in C++.
Friday, November 14, 2008
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment