Class ١
Class ١
struct
class
the only significant difference is the public keyword in the class.
declaration does not declare any memory. It only defines what
the class looks like
Function member
Using the “m_” prefix for member
variables helps distinguish member
variables from function parameters or
local variables inside member functions.
when we see an assignment to a
variable with the “m_” prefix we are
changing the state of the class.
Unlike function parameters or local
variables, which are declared within the
function, member variables are
declared
in the class definition.
Rule!!!! Name your classes starting with
a capital letter.
A class that allocates memory will deallocate it before
being destroyed), but it’s not safe to assume a struct will.
we recommend using the struct keyword for data-only
structures, and the class keyword for defining objects that
require both data and functions to be bundled together.
1 3
2
public protecte
private d
Public members are members of a struct or class that can be accessed from outside of
the struct or class.
Private members are members of a class that can only be accessed by other
members of the class.
All members of a struct are public members by default.
All members of a class are private members by
default.
error!!!
In general, member variables are usually made private, and member functions are usually
made public.
base and height