Lectures 7 8
Lectures 7 8
Lectures 7 8
class A {
int x;
void fun();
Any member (variable or
}; function) can be public or
private or protected
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 6
Classes (continued)
+: member is public
-: member is private
#: member is protected
C++ Programming: From Problem Analysis to Program Design, Fourth Edition 8
Variable (Object) Declaration
• Once a class is defined, you can declare
variables of that type
clockType myClock;
clockType yourClock;
• A class variable is called a class object or
class instance
w
i
t
h
:
s
e
t
T
i
m
e
(
h
o
u
r
s
,
m
i
n
Invoking a Constructor
• Example:
clockType yourClock;