By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,137 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,137 IT Pros & Developers. It's quick & easy.

struct vs. class usage

P: n/a
What is the difference between a struct and a class ?

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

Dec 29 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a

subramanian wrote:
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.

Dec 29 '06 #2

P: n/a

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

When should a struct be used and when should a class be used ?
FWIW this and many other things are covered in the associated faq:

http://www.parashift.com/c++-faq-lite/

regards
Andy Little

Dec 29 '06 #3

P: n/a
subramanian wrote:
What is the difference between a struct and a class ?

When should a struct be used and when should a class be used ?
This is a FAQ.

http://www.parashift.com/c++-faq-lit...s.html#faq-7.8
Dec 29 '06 #4

P: n/a

subramanian wrote:
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

Dec 29 '06 #5

P: n/a
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

Mohammad Omer Nasir wrote:
subramanian wrote:
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
Dec 29 '06 #6

P: n/a

Sandip Shahane wrote:
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.
>
Mohammad Omer Nasir wrote:
subramanian wrote:
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
Dec 29 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.