struct vs. class usage

S

subramanian

What is the difference between a struct and a class ?

When should a struct be used and when should a class be used ?
 
S

Salt_Peter

subramanian said:
What is the difference between a struct and a class ?

When should a struct be used and when should a class be used ?

The only difference is the name itself and the default access.
Some will suggest using struct for PODs (Palin Old Data).
Otherwise they are exactly the same.
 
M

Mohammad Omer Nasir

subramanian said:
What is the difference between a struct and a class ?

When should a struct be used and when should a class be used ?

as already few friends told access difference in struct and class but i
suggests you to write code related to struct in .c file and related to
class in .cpp file, after that one by one apply all concept of Object
Oriented Concept on both files then you will find crystal difference
between struct and class.

i hope it will helps you.

regards,

-aims
 
S

Sandip Shahane

Bingo asim!
Rest all differences mentioned are meant between "c++" struct and
class. But mind you, c and c++ structures are a lot different (see to
it like struct in c is given all OO power of class in c++)

Sandip Shahane
 
S

Salt_Peter

Sandip said:
Bingo asim!
Rest all differences mentioned are meant between "c++" struct and
class. But mind you, c and c++ structures are a lot different (see to
it like struct in c is given all OO power of class in c++)

Sandip Shahane

Please don't top Post.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top