Download presentation
Presentation is loading. Please wait.
Published byEdward Stephens Modified over 8 years ago
1
Introduction to OO Programming Andy Wang Object Oriented Programming in C++ COP 3330
2
Programming Program A list of instructions for a computer to execute
3
Evolution of Programming Languages Machine languages Numeric operations 0100 0101 0111 1111 0100 0110 0100 1100 0000 0001 0000 0000 0000 0000 0000 0010 0000 0000 0000 0011
4
Evolution of Programming Languages Assembly languages Human readable shorthand for operations.file“test.c”.section.rodata.LC0:.string “hello\n”.text.globl main.typemain, @function main: push1%ebp movl%esp, %ebp sub1%8, %esp
5
Evolution of Programming Languages High-level procedural languages More readable Can divide the work into actions, represented by procedures and functions E.g., C, Pascal main() { int x = 1; int y = 1; int r = 1; DrawCircle(x, y, r); }
6
but…computers only understand machine languages… A compiler (e.g., g++) translates programs written in high-level languages to machine code instructions An interpreter translates and executes programs on the fly High level languages Compiler / interpreter Machine languages
7
Evolution of Programming Languages Object-oriented languages Also high-level Encapsulate or group data and procedures into objects E.g., C++, Java class Circle { public: SetCenter(int x, int y); SetRadius(int r); Draw(); private: int x, y, radius; };
8
Thus, … C is a high-level procedural programming language C++ is an object-oriented language based on C
9
Object Encapsulation of data and functions that act upon that data An object consists of Name (variable name) Attributes (member data) that describe what the object is Behavior (member functions) that describes what the object does
10
Class A blueprint for objects A user-defined type, consists of Declaration (typically in.h files) Definition (typically in.cc files) An object is an instance of a class Can create many objects from the same class Can build many houses from the same blueprint
11
What’s special about objects? In C, a struct consists of a name (variable) and attributes (data inside the struct) Data and functions are separate In C++ Can build objects that encapsulate data and functions Can use classes as reusable program building blocks
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.