Presentation is loading. Please wait.

Presentation is loading. Please wait.

Classes Lecture 4 Secs 2.3, 4.1 – 4.3 Fri, Jan 26, 2007.

Similar presentations


Presentation on theme: "Classes Lecture 4 Secs 2.3, 4.1 – 4.3 Fri, Jan 26, 2007."— Presentation transcript:

1 Classes Lecture 4 Secs 2.3, 4.1 – 4.3 Fri, Jan 26, 2007

2 Classes The class construct in C++ is an enhancement of the struct construct in C. class Name { // Member function prototypes // Declarations of data members }; 7/5/2019 Classes

3 Class Members Members are private by default.
Members may be designated public, private, or protected. Members may be objects or functions. 7/5/2019 Classes

4 Class Member-Access Operators
Use the dot operator . to access members through an object. Use the arrow operator -> to access members through a pointer to an object. Point p(2, 3); cin >> p.x >> p.y; Point* pp = &p; cin >> pp->x >> pp->y; 7/5/2019 Classes

5 The Point Class The Point class point.h point.cpp 7/5/2019 Classes

6 Example: PointTest.cpp
7/5/2019 Classes


Download ppt "Classes Lecture 4 Secs 2.3, 4.1 – 4.3 Fri, Jan 26, 2007."

Similar presentations


Ads by Google