C++ Rules For Classes And Numbers
Learn about good programming practices for C++ regarding classes, containers, integers, and floating point numbers.
We'll cover the following
Classes
- Differentiate between
class
andstruct
, though the only formal difference between them is whether fields arepublic
by default or not. Usestruct
when you need a bunch ofpublic
fields with no non-trivial methods. Useclass
as a bunch ofprivate
fields with methods processing them. The following is an example ofstruct
:
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.