Download presentation
Presentation is loading. Please wait.
1
Programmer Defined Types and Classes
2
Review—Fundamental and Common C++ Types
Each type has two characteristics associated with it: allowable values allowable operations ex, int and bool Fundermental types: int, float, char, bool String type Aggregate type: arrays
3
Class and structure overview
A class is a data type whose variables are objects A class definition includes A description of the kinds of values the variable can hold A description of the member functions Examples: pre_defined class: int, char When you define a class, you are defining a new type structure A structure can be viewed as an object Contains no member functions Contains multiple values of possibly different types
4
Struct: the allowable values
The Certificate of Deposit structure can be defined as struct CDAccount { double balance; double interest_rate; int term; //months to maturity }; Remember this semicolon!
5
More programmer defined type example
Complex number struct complex_number { float r; float I; }; COMPLEX.H COMPLEX.CPP COMPLEX_APP.CPP
6
More example Example: complex_op.h, complex_op.cpp, complex_op_app.cpp
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.