answersLogoWhite

0


Best Answer

The only difference between a struct and a class is that struct members are public by default while class members are private by default. To demonstrate, consider the following code:

#include<iostream>

struct struct_object

{

int m_data;

};

class class_object

{

int m_data;

};

int main()

{

struct_object s;

class_object c;

s.m_data = 42; // ok -- s.m_data has public access by default.

c.m_data = 42; // access denied -- c.m_data is private by default.

}

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Could you Cite examples to show difference between structures and classes?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between classes and structure?

Classes are expanded concepts of structures, and can hold functions along with variables and other information.


What's the difference between Classes 375 377 and 379?

The difference between the Classes 375 377 and 379 is the services that are provided to the customer.


What is the difference between classes of IP addresses?

difference between ip address and class


What's the difference between the British Rail Classes 313 315 and 317?

The difference between the British Rail Classes 313,314 and 317 is the different locations in which they are used.


What are the differences between a C structure and C class?

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.


What is the most significant difference between the holdovers and animals in all other classes?

what's the most significant difference between the holdovers" and animals in all other classes. what's the answer.


What is Difference between C structers and classes?

through classes we can create objects and we can implemented businessmathods. in case of structres we can create streuctre variables but not methods this is the major difference


What is the difference between honor classes and regular classes?

Honor classes give you college credit, if you are stating from a High School standpoint. If not, honor classes give you more credits than regular classes.


What are the basic program structures in visual basic?

Classes Structures Subroutines Functions


What is the difference between modifier and identifier?

Identifiers are names you give to variables,methods,namespaces,classes ...ext Modifiers are used to modify declarations of types and type members . examples for modifiers : pivate ,public ,const , ...


What is difference between classes and modules?

i think module life cycle manage program..


What is Neto's Voodoo Figure trying to show the difference between?

the upper and lower classes