The differences among struct in C, in C++ and the class in C++

The difference between struct in C and struct in C++:

1. The struct in C can not contain function while the struct in C++ can.

2. The struct in C does not have access control such as private, public and protected, while the struct in C++ does.

3. The struct in C does not have the inheritance mechanism, while the struct in C++ does.

There are only small difference between struct and class in C++:

1. The inheritance of struct in C++ is default set to be public, while the inheritance of class in C++ is default set to be private.

2. The variable of struct in C++ is default set to be public, while the variable of class in C++ is default set to be private.

Advertisements
This entry was posted in C++. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s