Object-Oriented Programming (Oop) and C++: Cpts 122 - Fall 2019 Washington State University
Object-Oriented Programming (Oop) and C++: Cpts 122 - Fall 2019 Washington State University
Nadra Guizani
Object-
Oriented
Design (OOD)
Nadra Guizani
Object-Oriented Design (OOD)
• Programming language model which institutes mechanisms to
support implementing object driven software systems
– C++, C#, Java
• In a procedural program:
- Have data stored in a collection of variables and/or
structures,
- Coupled with a set of functions that perform operations on
the data
-C
Nadra Guizani
Object-Oriented Design (OOD)
• In C, the unit of programming is a function
Nadra Guizani
Basics of C++ and I/O Example
Nadra Guizani
C to C++ Example
Basics of C++ --
References and Reference Parameters
• There are two ways to pass arguments to functions in C++
Nadra Guizani
Unary Scope Resolution Operator
• It’s possible to declare local and global variables of the same name
• (::) allows a global variable to be accessed without confusing it with a local
variable
Nadra Guizani
Function Overloading
• The ability to define multiple functions with the same name
• Requires that each function has
• different types of parameters
• different number of parameters
• different order of parameters
What is an object?
– An instantiation of a class
– The class is the type and the object is the variable with allocated
memory for that type
Nadra Guizani
Classes and
Objects
Nadra Guizani
Reference:
• Chapter 2-6: C++ Starting from control structures through objects 8th
edition.
• P.J. Deitel & H.M. Deitel, C++: How to Program (9th ed.), Prentice Hall,
2014.
Nadra Guizani