Computer Science, asked by Sunny9683, 10 months ago

Difference and similarities between structures in c and classes in c++

Answers

Answered by sushiladevi4418
0

Answer:

Difference and similarities between structures in c and classes in c++

Explanation:

It's true that C++ supports structures to remain backward compatible with C & provide easy migration path to C programmers.

But there are still many differences between C struct & C++ struct.

C:

1) C structure can't contain functions means only data members are allowed,

2) Struct keyword is necessary in C to create structure type variable.  

3) Structure in C can't have static members.

C++

1) Structure in C++ can have both functions & data members.

2) It is redundant & not necessary in C++.

3)  C++ structure can have static members.

Similar questions