answersLogoWhite

0


Best Answer

The main difference between a class and a structure is that structures are always public whereas classes are private by default. Classes give greater control as the interface can be engineered such that only code that requires access to specific class members gains that access. Everything else can be hidden within the class itself.

Note that C does not support classes, period. Classes are only supported by C++. However C++ also supports C structures for backward compatibility with C-style code.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the differences between a C structure and C class?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a program to show array within class in c?

class is defined in c++ my dear so in C there is no structure of class.for c++ class private { int x[10],y; cout


What is the difference between structure and class with example?

Structures are public by default whereas classes are private by default. Other than that they are exactly the same. struct s { int num; // s.num is accessible outside of the structure }; class c { int num; // c.num is only accessible to the class itself. };


What are the advantages of structure in c plus plus?

They are primarily included to retain compatibility with C. However, structures are public by default. So if you don't require the data hiding capability of a class, a struct is a suitable alternative. Also, when mixing C and C++ code, there may be a requirement to typecast a class to a struct and vice versa.


What is the differences between break in c?

Nothing, it is the same thing.


Differences between harmonica key A and key C?

Pitch


What is the Difference between b and c class MS pipe?

The main difference is the thickness of the pipe Compare to A Class pipe B Class pipe thickness is more.Like that Compare to B class pipe C Class pipe thickness is more.


What is the difference between a structure in C and a structure in C-plus-plus?

Not much. C++ structures are the same, i.e., still declared with "struct".. Are you sure that you didn't mean to ask: "What's the difference between a structure and a class?" Cause, that's the main (DRUMROLL PLEASE) power of C++, among other things. I think there is a difference in them. In struct of C there are no Member functions allowed .( you can use function pointer but not the definition in the structure ). But in C++ you have that flexibility . A C++ struct is exactly the same as a C++ class, except that struct members are public by default while class members are private by default. Access to individual members can be overridden in the declaration thus either can be used for the same purpose. C++ programmers use classes to define most object types and reserve the struct type for backward-compatibility with C.A C struct has member variables but has no methods. Accessibility cannot be defined, thus all members are effectively public at all times.


What is the difference between a class A felony and a class C?

Class A is the most serious and has more severe penalties.


Compare and Contrast technical similarities and differences between TinyC, C and C++ Compilers?

[object Object]


Definition of structure in c plus plus?

A structure is a collection of variables referenced under one name, providing a convenient means of keeping related information together. A structure declaration forms a template that may be used to create structure objects (that is, instances of a structure). The variables that make up the structure are called members. (Structure members are also commonly referred to as elements or fields).


What is the differences between carbon-carbon double bond and carbon-oxygen double bond?

similarity: both have bonds involving four shared electrons. differences: c=o is polar; c=c is not polar.


Defference between c plus plus and c?

these are difference in between c and c++: a) C is a SPL and C++ is a OOP. b) C has not concept of object but C++ has this feature. c) C has not 'class' name data type but C++ has.