answersLogoWhite

0


Best Answer

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.

};

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between structure and class with example?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is difference between struct variable and class object?

structure variable can access the variable but class object can access the function also


Difference between a class and a struct?

By default, all of the members of a class are private and, by default, all of the members of a structure are public.Structure are value type where as class are reference type.'this' pointer will work only in class.Inheritance between classes is also private by default, and inheritance between structs is public by default.Classes support polymorphism, whereas structure do not.


What's the difference between the Class 365 and Class 465 466?

The difference between the Class 365 and Class 465, 466 is basically the cost.


Difference between exclusive or inclusive class intervals?

difference between inclusive and exclusive class interval


What is the difference between a class A B and C drug?

Class A drugs are the drugs that are most dangerous for example cocaine. Class B drugs are the drugs that are mildly dangerous. Class C drugs are the drugs that are least dangerous for example cannabis.


What is difference between first class and second class on train trips?

What is the difference between buying a 1st class and a 2nd class ticket on the train in England?


What are aristocracy middle class and slaves are example of what kind of structure?

no


What is the connection between class structure and economic development?

The answer is the difference between democrates and republicans. Republicans develope so democrates can structure class. The takers (democrates) and the doers (republicans). If allowed the democrates would have us all giving so their "chosen" could have everything and then pitey all of us without.


What is the difference between a class What is the difference between a class III and class IV hitch and?

class III rated for up to 5,000lbs, class IV is rated for up to 10,000lbs towing capacity


What is the difference between abstract class and final class?

20


Difference between Mercedes e class elegance and classic?

What is the difference between Mercedes Benz E class 'Elegance'and classic


What is the difference between data structure and abstract data type?

An Abstract Data Type is an interface that interacts with a data structure. A Data Structure is an implementation of the ADT. for example. If you were going to create a linked list you would create an Interface listing all the methods required by the list. Then in the linked list class you would code how the list uses these methods. Hope this helps :)