Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does C++ have both classes and structs? [duplicate]

Tags:

c++

class

struct

Possible Duplicate:
What are the differences between struct and class in C++

If the only difference between structs and classes is the default access specifier(in C++), then why does C++ also have classes?

like image 517
Lockhead Avatar asked Apr 20 '11 20:04

Lockhead


1 Answers

First, it's backward compatibility with C. Second (and more importantly), it helps describe your intent. The standard convention is that PODs should be denoted with struct and collections of data and behavior should be denoted with class.

like image 151
Bill Avatar answered Sep 18 '22 12:09

Bill