Could anybody please tell me what is the main difference
between C & C++ structures.
Could anybody please tell me what is the main difference between C & C++
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In C++
structandclassare the exact same thing, except for that struct defaults topublicvisibility and class defaults toprivatevisiblity.In C, struct names are in their own namespace, so if you have
struct Foo {};, you need to writestruct Foo foo;to create a variable of that type, while in C++ you can write justFoo foo;, albeit the C style is also permitted. C programmers usually usetypedef struct {} Foo;to allow the C++ syntax for variable definitions.The C programming language also does not support visibility restrictions, member functions or inheritance.