EL2310 Scientific Programming

Size: px
Start display at page:

Download "EL2310 Scientific Programming"

Transcription

1 Lecture 14: Object Oriented Programming in C++

2 Overview Overview Lecture 14: Object Oriented Programming in C++ Wrap Up Introduction to Object Oriented Paradigm Classes More on Classes and Members Operator Overloading Inheritance Polymorphism and Virtual Functions The Standard Template Library (STL)

3 Last time Intro to C++ Differences between C and C++ Intro to OOP

4 Today Object Oriented Programming Classes

5 Wrap Up Lecture 14: Object Oriented Programming in C++ Wrap Up Introduction to Object Oriented Paradigm Classes More on Classes and Members Operator Overloading Inheritance Polymorphism and Virtual Functions The Standard Template Library (STL)

6 Wrap Up C++ Compiler Use g++ instead of gcc Usage and command line options are the same as for gcc Make sure you know how to use make for this part of the course!

7 Wrap Up Declaration of variables You no longer need to declare the variable at the beginning of the function (scope), as was the case for pre C99 Useful rule of thumb: Declare variables close to where they re used. For instance: i only defined within loop for(int i=0;i<n;i++){...} Use specific names for counters, e.g. i,j,k,...

8 Wrap Up Namespaces In C all function share a common namespace This means that there can only be one function for each function name In C++ can be placed in namespaces Syntax: namespace NamespaceName { void fcn();... } To access a function fcn in namespace A A::fcn To avid typing namespace name in every statement: using namespace std

9 Wrap Up Printing to Screen In C++ we use streams for input and output Output is handled with the stream cout and cerr In C: printf("the value is %d\n", value); In C++: cout << "The value is " << value << endl; Just like in C you can format the output in a stream You can use cout.width(10) number of characters for output to fill cout.precision(3) number of digits cout.fill( 0 ) pad with a certain character

10 Wrap Up Getting input from the user Use streams also to get input from console Use the cin stream Ex: int value; cin >> value; If you want to read an entire line, use getline Ex: string line; getline(cin, line); cout << "The input was " << line << endl;

11 Wrap Up References Constrained and safer pointers Compare int a; int a; int *pa = &a; int &ra = a; int *pa = NULL; - *pa = 10; ra = 10; => a==10 int b; int b; pa = &b; - int *pc; - pc = pa; -

12 Wrap Up Passing Arguments by Reference in C++ Declaration: void fcn(int &x); Any changed to x inside fcn will affect the parameter used in the function call Ex: void fcn(int &x) { x = 42; } int main() { int x = 1; fcn(x); cout << "x=" << x << endl; } Will change value of x in the scope of main to 42

13 Wrap Up Dynamic Memory Allocation in C++ In C++ the new and delete operators are used In C we used malloc and free If you allocate an array with new you need to delete with delete [] Ex: int *p = new int[10]; p[0] = 42; delete [] p; Typical mistake, forgotten []

14 Introduction to Object Oriented Paradigm Lecture 14: Object Oriented Programming in C++ Wrap Up Introduction to Object Oriented Paradigm Classes More on Classes and Members Operator Overloading Inheritance Polymorphism and Virtual Functions The Standard Template Library (STL)

15 Introduction to Object Oriented Paradigm The Object-Oriented Paradigm The motivation: We are trying to solve complex problems Complex code with many functions and names Difficult to keep track of all details How can we deal with the complexity? Grouping related things Abstracting things away Creating hierarchies of things This also improves: Code re-use Reliability and debugging

16 Introduction to Object Oriented Paradigm Key Concepts of OOP Classes (types) Instances (objects) Methods Interfaces Access protection - information hiding Encapsulation Composition / aggregation Inheritance Polymorphism

17 Classes Lecture 14: Object Oriented Programming in C++ Wrap Up Introduction to Object Oriented Paradigm Classes More on Classes and Members Operator Overloading Inheritance Polymorphism and Virtual Functions The Standard Template Library (STL)

18 Classes Classes A class is an extension of a struct A class can have both data member and function members (methods) Classes bring together data and operations related to that data Like C structs, classes define new data types Unlike structs, they also define how operators work on the new types

19 Classes Class definition Syntax: class ClassName { public: void fcn(); private: int m X; }; // Do not forget the semicolon!!! m X is a member data void fcn() is a member function public is an access specifier specifying that everything below can be access from outside the class private is an access specifier specifying that everything below is hidden from outside of the class

20 Classes Access specifiers There are three access specifiers: public private protected No access specifier specified assumes it is private Data and function members that are private cannot be accessed from outside the class Ex: m X above cannot be accessed from outside protected will be discussed later

21 Classes C++ Structs C++ also uses struct In C++ struct is just like a class (much more than the C struct!) The only difference is the default access protection: class Name { int m X; // Private }; struct Name { int m X; // Public };

22 Classes Classes and Objects Classes define data types Objects are instances of classes Objects correspond to variables Declaring an object: ClassName variablename;

23 Classes Classes and Namespace The class defines a namespace Hence function names inside a class do not name clash with other functions Example: the member variable m X above is fully specified as ClassName::m X

24 Classes Constructor When an object of a certain class is created the so called constructor is called Constructor is a special kind of method. The constructor tells how to setup the objects The constructor that does not take any arguments is called the default constructor The constructor has the same name as the class and has no return type class A { public: A() {} };

25 Classes Constructor Some types cannot be assigned, only initialized, e.g. references These data members should be initialized in the initializer list of the constructor Try to do as much of the initialization in the initialization in the list rather than using assignment in the body of the constructor Variables are initialized in the order they appear in the list class A { public: A():m X(1) {} private: int m X; };

26 Classes Constructor class A { public: A():m X(1) {} int getvalue() { return m X; } private: int m X; }; A a; std::cout << a.getvalue() << std::endl;

27 Classes Constructor You can define several different constructors class MyClass { public: MyClass():m X(1) {} MyClass(int value):m X(value) {} int getvalue() { return m X; } private: int m X; }; MyClass a; // Default constructor MyClass aa(42); // Constructor with argument std::cout << a.getvalue() << std::endl; std::cout << aa.getvalue() << std::endl;

28 Classes Destructor When an object is deleted the destructor is called The destructor should clean up things For example free up dynamically allocated memory There is only 1 destructor If not declared a default one is used which will not free up dynamic memory Syntax: ClassName(); Class A { public: A(); // Constructor A(); // Destructor... };

29 Classes Let s look at an example

30 Classes Task 1 Implement a class the defines a Car Should have a member variable for number of wheels Should have methods to get the number of wheels Write program that instantiate a Car and print number of wheels

31 Classes Task 2 Write a class Complex for a complex number Provide 3 constructors default - which should create a complex number with value 0 having one argument - should create a real value having two arguments - should create a complex number with real and imaginary part

32 Classes Source and header file Normally you split the definition from the declaration like in C The definition goes into the header file.h The declaration goes into the source file.cpp Header file ex: class A{ public: A(); private: int m X; }; Source file ex: #include "A.h" A::A():m X(0)

33 More on Classes and Members Lecture 14: Object Oriented Programming in C++ Wrap Up Introduction to Object Oriented Paradigm Classes More on Classes and Members Operator Overloading Inheritance Polymorphism and Virtual Functions The Standard Template Library (STL)

34 More on Classes and Members this pointer Inside class methods you can refer to the object with this pointer The this pointer cannot be assigned (done automatically) Example use in our toy constructor example.

35 More on Classes and Members const Can have const function arguments Ex: void fcn(const string &s); Pass the string as a reference into the function but commit to not change it For classes this can be used to commit to not change an object as well Ex: void fcn(int arg) const; The function fcn commits to not change anything in the object it belongs to Can only call const functions from a const function or with a const object

36 More on Classes and Members Static members Members (both functions and data) can be declared static A static member is the same across all objects; it s a member of the class, not any single object That is all instantiated objects share the same static member You can use a static class member without instantiating any object You need to define static data member Ex: (in source file) int A::m Counter = 0; if m Counter is a static data member of class A Static methods can only use static data members! Car example

37 More on Classes and Members Task 3 Start from the Complex class from last time Add a static int member Every time a new complex number is created the static variable should be incremented Implement the member function Complex& add(const Complex &c); which should add c to the object How does the number of created objects change if we change the function to Complex& add(complex c);

38 Operator Overloading Lecture 14: Object Oriented Programming in C++ Wrap Up Introduction to Object Oriented Paradigm Classes More on Classes and Members Operator Overloading Inheritance Polymorphism and Virtual Functions The Standard Template Library (STL)

39 Operator Overloading Operator overloading Operators behave just like functions Compare Complex& add(const Complex &c); Complex& +=(const Complex &c); You can overload (provide your own implementation of) most operators This way you can make them behave in a proper way for your class It will not change the behavior for other classes only the one which overloads the operator Some operators are member functions, some are defined outside class

40 Operator Overloading Task 4 Use the Complex number class from before. Overload/implement: std::ostream& operator<<(std::ostream &os, const Complex &c); Complex operator+(const Complex &c1, const Complex &c2) Complex operator+(const Complex &c); function) Complex& operator=(const Complex &c); function) (member (member

41 Operator Overloading Function overloading We can create functions and methods with the same name, but different arguments It is not possible to overload by changing return type Example: void method(); void method(int a); void method(int b, double c); void method(int b); WRONG! int method(int b); WRONG!

42 Operator Overloading Let s look at operator overloading for the car example. Use case for overloading << Use case for overloading =

43 Operator Overloading Dynamic allocation of objects One reason to use dynamic memory allocation (new/delete): Moving around pointers to BIG chunks of memory (avoiding unnecessary copying) Makes sense not only for arrays Objects can also be BIG (e.g. database object can be 500MB!) Typically, we dynamically allocate objects We free memory when the object is no longer needed We pass objects by reference (* or &) to functions Example: Database db = new Database("mydatabase.db"); usedb(db); // void usedb(database *db) delete db; db = NULL;

44 Inheritance Lecture 14: Object Oriented Programming in C++ Wrap Up Introduction to Object Oriented Paradigm Classes More on Classes and Members Operator Overloading Inheritance Polymorphism and Virtual Functions The Standard Template Library (STL)

45 Inheritance Inheritance Inheritance is a way to show a relation like is a Ex: a car is a vehicle A car inherits many of its properties from being a vehicle These same properties could be inherited by a truck or a bus Syntax: class Car : public Vehicle specifies that Car inherits from Vehicle

46 Inheritance Inheritance and Constructors If you have three classes A, B and C, where B inherits from A (class B: public A) C inherits from B (class C: public B) When you create C: C c; the constructor from the base classes (B and A) will be run first Execution order 1. Constructor of A 2. Constructor of B 3. Constructor of C

47 Inheritance Access specifiers private: can be accessed from: inside of the class public: can be accessed from: inside of the class subclasses outside of the class protected: can be accessed from: inside of the class subclasses

48 Inheritance Class diagrams / UML

49 Polymorphism and Virtual Functions Lecture 14: Object Oriented Programming in C++ Wrap Up Introduction to Object Oriented Paradigm Classes More on Classes and Members Operator Overloading Inheritance Polymorphism and Virtual Functions The Standard Template Library (STL)

50 Polymorphism and Virtual Functions Polymorphism A variable/function can have more than one form Example of polymorphism: operator/function overloading We can have sub-type polymorphism: a variable can be of more than one form A variable of a base type can hold an object of a sub-type In C++ implemented using references or pointers to base classes

51 Polymorphism and Virtual Functions Polymorphism example class Vehicle {...} class Car: public Vehicle {...} Vehicle *v1 = new Vehicle(); Vehicle *v2 = new Car(); v2 is a Car hidden inside a variable of type pointer to Vehicle! We can then write: v1 = new Car(); So, v1 can hold both a Car and a Vehicle (or even a Truck!) Polymorphism!

52 Polymorphism and Virtual Functions Subclasses as arguments to function If a function requires as argument a pointer/reference to an object of class A We can provide a pointer/reference to any subclass of A

53 Polymorphism and Virtual Functions Accessing methods class Vehicle { void drive(); } class Car: public Vehicle { void opentrunk(); } Vehicle *v = new Car(); v->drive(); runs drive() from the Vehicle part of the Car v->opentrunk(); NOT POSSIBLE! But: ((Car *)v)->opentunk(); WORKS!

54 Polymorphism and Virtual Functions Overloading in sub-classes We can overload a method in a sub-class class Vehicle { void drive(); } class Car: public Vehicle { void drive(); } Vehicle *v1 = new Vehicle(); Vehicle *v2 = new Car(); Car *c = new Car(); v1->drive(); and v2->drive(); run drive() from the Vehicle c->drive(); runs drive() from the Car

55 Polymorphism and Virtual Functions virtual functions What if we want the object know what it really is and run the correct drive() method? Declare the method with the keyword virtual class Vehicle { virtual void drive(); } class Car: public Vehicle { virtual void drive(); } Vehicle *v1 = new Vehicle(); Vehicle *v2 = new Car(); v1->drive(); runs drive() from the Vehicle v2->drive(); runs drive() from the Car

56 Polymorphism and Virtual Functions Polymorphism with virtual functions What virtual function to run is determined at run-time Depends on the real type of objects Works for both pointers and references

57 Polymorphism and Virtual Functions The C project Deadline: Monday , 20:00 Lab/help session: Friday , 9-11:00am, Room 22:an, Teknikringen 14

58 The Standard Template Library (STL) Lecture 14: Object Oriented Programming in C++ Wrap Up Introduction to Object Oriented Paradigm Classes More on Classes and Members Operator Overloading Inheritance Polymorphism and Virtual Functions The Standard Template Library (STL)

59 The Standard Template Library (STL) Template Templates offers a way to write code agnostic to data types You write a template for the code Compiler generates a version for each data type you use it with We can write both template classes and functions Example of a template function: template <class T> T getmax (T a, T b) { if(a>b) {return a} else {return b} } getmax<int>(4,5) returns 5 getmax<double>(4.2, 4.1) returns 4.2

60 The Standard Template Library (STL) Standard Template Library: STL The Standard Template Library (STL) provides classes for: Collections: lists, vectors, sets, maps Defined as templates: can store data of any type! Examples: std::list<t> Ex: std::list<std::string> names; std::vector<t> Ex: std::vector<double> values; std::set<t> Ex: std::set<std::string> nameofperson; std::map<t1,t2> Ex: std::map<int, std::string> nameofmonth; Ex: std::map<std::string, int> monthnumberbyname;

61 The Standard Template Library (STL) Standard Template Library: STL Different collections are optimized for different use, e.g.: std::list<t> Cannot access elements with x[i], need to use so called iterators to step through the list, can add/remove elements at low cost std::vector<t> Can access elements with x[i], but resizing is more costly std::set<t> Does not allow for redundant elements std::map<t1,t2> Provides a mapping from one object to another More in C++ Library Reference, e.g.

62 The Standard Template Library (STL) Often used: vector (from C++ reference) // erasing from vector #include <iostream> #include <vector> using namespace std; int main () { unsigned int i; vector<unsigned int> myvector; } // set some values (from 1 to 10) for (i=1; i<=10; i++) myvector.push_back(i);

63 The Standard Template Library (STL) Often used: vector (from C++ reference) // erase the 6th element myvector.erase(myvector.begin()+5); // erase the first 3 elements: myvector.erase(myvector.begin(), myvector.begin()+3); cout << "myvector contains:"; for (i=0; i<myvector.size(); i++) { cout << " " << myvector[i]; cout << endl; } return 0;

64 The Standard Template Library (STL) Standard Template Library: STL What would be suitable STL structures for: A queue of real time messages? A set of options? Modelling a shipment of products? Differences are important: How to insert an element? How to access/find an element? How to remove an element?

65 The Standard Template Library (STL) Standard Template Library: STL What would be suitable STL structures for: A queue of real time messages? A set of options? Modelling a shipment of products? Differences are important: How to insert an element? How to access/find an element? How to remove an element?

66 The Standard Template Library (STL) Presentation 18 on 16. Oct Find out about Expectation-Maximization (EM) algorithm and Monte Carlo Sampling for inference and approximation. Implement examples in C++

EL2310 Scientific Programming

EL2310 Scientific Programming (pronobis@kth.se) Overview Overview Wrap Up Introduction to Object Oriented Paradigm More on and Members Operator Overloading Last time Intro to C++ Differences between C and C++ Intro to OOP Today Object

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 14: Object Oriented Programming in C++ (ramviyas@kth.se) Overview Overview Lecture 14: Object Oriented Programming in C++ Classes (cont d) More on Classes and Members Group presentations Last time

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 15: Inheritance and Polymorphism, STL (pronobis@kth.se) Overview Overview Lecture 15: Inheritance and Polymorphism, STL Wrap Up Additional Bits about Classes Overloading Inheritance Polymorphism

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 16: STL, C++1y (ramviyas@kth.se) Overview Overview Lecture 16: STL and C++1y Reminders Wrap up C++11 Reminders The help sessions and deadline C++ help session: Fri 24.10.2015, 15:00-17:00, Room

More information

CSE 303: Concepts and Tools for Software Development

CSE 303: Concepts and Tools for Software Development CSE 303: Concepts and Tools for Software Development Hal Perkins Autumn 2008 Lecture 24 Introduction to C++ CSE303 Autumn 2008, Lecture 24 1 C++ C++ is an enormous language: All of C Classes and objects

More information

Programming, numerics and optimization

Programming, numerics and optimization Programming, numerics and optimization Lecture A-4: Object-oriented programming Łukasz Jankowski ljank@ippt.pan.pl Institute of Fundamental Technological Research Room 4.32, Phone +22.8261281 ext. 428

More information

CSE 374 Programming Concepts & Tools. Hal Perkins Spring 2010

CSE 374 Programming Concepts & Tools. Hal Perkins Spring 2010 CSE 374 Programming Concepts & Tools Hal Perkins Spring 2010 Lecture 19 Introduction ti to C++ C++ C++ is an enormous language: g All of C Classes and objects (kind of like Java, some crucial differences)

More information

eingebetteter Systeme

eingebetteter Systeme Praktikum: Entwicklung interaktiver eingebetteter Systeme C++-Tutorial (falk@cs.fau.de) 1 Agenda Classes Pointers and References Functions and Methods Function and Operator Overloading Template Classes

More information

CS11 Introduction to C++ Fall Lecture 1

CS11 Introduction to C++ Fall Lecture 1 CS11 Introduction to C++ Fall 2006-2007 Lecture 1 Welcome! 8 Lectures (~1 hour) Slides posted on CS11 website http://www.cs.caltech.edu/courses/cs11 7 Lab Assignments on course website Available on Monday

More information

C++ (Non for C Programmer) (BT307) 40 Hours

C++ (Non for C Programmer) (BT307) 40 Hours C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular

More information

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 19 Introduction to C++

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 19 Introduction to C++ CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 19 Introduction to C++ C++ C++ is an enormous language: All of C Classes and objects (kind of like Java, some crucial differences) Many

More information

CS24 Week 3 Lecture 1

CS24 Week 3 Lecture 1 CS24 Week 3 Lecture 1 Kyle Dewey Overview Some minor C++ points ADT Review Object-oriented Programming C++ Classes Constructors Destructors More minor Points (if time) Key Minor Points const Motivation

More information

G52CPP C++ Programming Lecture 14. Dr Jason Atkin

G52CPP C++ Programming Lecture 14. Dr Jason Atkin G52CPP C++ Programming Lecture 14 Dr Jason Atkin 1 Last Lecture Automatically created methods: A default constructor so that objects can be created without defining a constructor A copy constructor used

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

Interview Questions of C++

Interview Questions of C++ Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.

More information

Part VII. Object-Oriented Programming. Philip Blakely (LSC) C++ Introduction 194 / 370

Part VII. Object-Oriented Programming. Philip Blakely (LSC) C++ Introduction 194 / 370 Part VII Object-Oriented Programming Philip Blakely (LSC) C++ Introduction 194 / 370 OOP Outline 24 Object-Oriented Programming 25 Member functions 26 Constructors 27 Destructors 28 More constructors Philip

More information

(5-1) Object-Oriented Programming (OOP) and C++ Instructor - Andrew S. O Fallon CptS 122 (February 4, 2019) Washington State University

(5-1) Object-Oriented Programming (OOP) and C++ Instructor - Andrew S. O Fallon CptS 122 (February 4, 2019) Washington State University (5-1) Object-Oriented Programming (OOP) and C++ Instructor - Andrew S. O Fallon CptS 122 (February 4, 2019) Washington State University Key Concepts 2 Object-Oriented Design Object-Oriented Programming

More information

G52CPP C++ Programming Lecture 18. Dr Jason Atkin

G52CPP C++ Programming Lecture 18. Dr Jason Atkin G52CPP C++ Programming Lecture 18 Dr Jason Atkin 1 Last lecture Operator Overloading Strings and streams 2 Operator overloading - what to know Know that you can change the meaning of operators Know that

More information

CSE 333. Lecture 9 - intro to C++ Hal Perkins Department of Computer Science & Engineering University of Washington

CSE 333. Lecture 9 - intro to C++ Hal Perkins Department of Computer Science & Engineering University of Washington CSE 333 Lecture 9 - intro to C++ Hal Perkins Department of Computer Science & Engineering University of Washington Administrivia New exercise posted yesterday afternoon, due Monday morning - Read a directory

More information

AN OVERVIEW OF C++ 1

AN OVERVIEW OF C++ 1 AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function

More information

CS

CS CS 1666 www.cs.pitt.edu/~nlf4/cs1666/ Programming in C++ First, some praise for C++ "It certainly has its good points. But by and large I think it s a bad language. It does a lot of things half well and

More information

CSI33 Data Structures

CSI33 Data Structures Outline Department of Mathematics and Computer Science Bronx Community College November 9, 2016 Outline Outline 1 Chapter 9: C++ Classes Outline Chapter 9: C++ Classes 1 Chapter 9: C++ Classes Class Syntax

More information

PHY4321 Summary Notes

PHY4321 Summary Notes PHY4321 Summary Notes The next few pages contain some helpful notes that summarize some of the more useful material from the lecture notes. Be aware, though, that this is not a complete set and doesn t

More information

CS11 Intro C++ Spring 2018 Lecture 1

CS11 Intro C++ Spring 2018 Lecture 1 CS11 Intro C++ Spring 2018 Lecture 1 Welcome to CS11 Intro C++! An introduction to the C++ programming language and tools Prerequisites: CS11 C track, or equivalent experience with a curly-brace language,

More information

CS93SI Handout 04 Spring 2006 Apr Review Answers

CS93SI Handout 04 Spring 2006 Apr Review Answers CS93SI Handout 04 Spring 2006 Apr 6 2006 Review Answers I promised answers to these questions, so here they are. I'll probably readdress the most important of these over and over again, so it's not terribly

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Data Structures using OOP C++ Lecture 3

Data Structures using OOP C++ Lecture 3 References: th 1. E Balagurusamy, Object Oriented Programming with C++, 4 edition, McGraw-Hill 2008. 2. Robert L. Kruse and Alexander J. Ryba, Data Structures and Program Design in C++, Prentice-Hall 2000.

More information

Department of Computer science and Engineering Sub. Name: Object oriented programming and data structures Sub. Code: EC6301 Sem/Class: III/II-ECE Staff name: M.Kavipriya Two Mark Questions UNIT-1 1. List

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

COMSW Introduction to Computer Programming in C

COMSW Introduction to Computer Programming in C OMSW 1003-1 Introduction to omputer Programming in Lecture 23 Spring 2011 Instructor: Michele Merler http://www1.cs.columbia.edu/~mmerler/comsw1003-1.html 1 Today Trees (from PP hapter 17) ++ and object

More information

Review: C++ Basic Concepts. Dr. Yingwu Zhu

Review: C++ Basic Concepts. Dr. Yingwu Zhu Review: C++ Basic Concepts Dr. Yingwu Zhu Outline C++ class declaration Constructor Overloading functions Overloading operators Destructor Redundant declaration A Real-World Example Question #1: How to

More information

CE221 Programming in C++ Part 1 Introduction

CE221 Programming in C++ Part 1 Introduction CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab

More information

Engineering Tools III: OOP in C++

Engineering Tools III: OOP in C++ Engineering Tools III: OOP in C++ Engineering Tools III: OOP in C++ Why C++? C++ as a powerful and ubiquitous tool for programming of numerical simulations super-computers (and other number-crunchers)

More information

Lecture 14: more class, C++ streams

Lecture 14: more class, C++ streams CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 14:

More information

CSCI 102L - Data Structures Midterm Exam #1 Fall 2011

CSCI 102L - Data Structures Midterm Exam #1 Fall 2011 Print Your Name: Page 1 of 8 Signature: Aludra Loginname: CSCI 102L - Data Structures Midterm Exam #1 Fall 2011 (10:00am - 11:12am, Wednesday, October 5) Instructor: Bill Cheng Problems Problem #1 (24

More information

III. Classes (Chap. 3)

III. Classes (Chap. 3) III. Classes III-1 III. Classes (Chap. 3) As we have seen, C++ data types can be classified as: Fundamental (or simple or scalar): A data object of one of these types is a single object. int, double, char,

More information

Classes, Constructors, etc., in C++

Classes, Constructors, etc., in C++ Classes, Constructors, etc., in C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute

More information

COMP322 - Introduction to C++

COMP322 - Introduction to C++ COMP322 - Introduction to C++ Winter 2011 Lecture 05 - I/O using the standard library & Introduction to Classes Milena Scaccia School of Computer Science McGill University February 1, 2011 Final note on

More information

Object-Oriented Programming (OOP) Fundamental Principles of OOP

Object-Oriented Programming (OOP) Fundamental Principles of OOP Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is

More information

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am CMSC 202 Section 010x Spring 2007 Computer Science II Final Exam Name: Username: Score Max Section: (check one) 0101 - Justin Martineau, Tuesday 11:30am 0102 - Sandeep Balijepalli, Thursday 11:30am 0103

More information

And Even More and More C++ Fundamentals of Computer Science

And Even More and More C++ Fundamentals of Computer Science And Even More and More C++ Fundamentals of Computer Science Outline C++ Classes Special Members Friendship Classes are an expanded version of data structures (structs) Like structs, the hold data members

More information

C++ Mini-Course. Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion. C Rulez!

C++ Mini-Course. Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion. C Rulez! C++ Mini-Course Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion C Rulez! C++ Rulez! C++ Mini-Course Part 1: Mechanics C++ is a

More information

Chapter 10 Introduction to Classes

Chapter 10 Introduction to Classes C++ for Engineers and Scientists Third Edition Chapter 10 Introduction to Classes CSc 10200! Introduction to Computing Lecture 20-21 Edgardo Molina Fall 2013 City College of New York 2 Objectives In this

More information

Software Engineering Concepts: Invariants Silently Written & Called Functions Simple Class Example

Software Engineering Concepts: Invariants Silently Written & Called Functions Simple Class Example Software Engineering Concepts: Invariants Silently Written & Called Functions Simple Class Example CS 311 Data Structures and Algorithms Lecture Slides Friday, September 11, 2009 continued Glenn G. Chappell

More information

Object Oriented Programming in C++

Object Oriented Programming in C++ Object Oriented Programming in C++ Jan Faigl Department of Computer Science Faculty of Electrical Engineering Czech Technical University in Prague Lecture 11 B3B36PRG C Programming Language Jan Faigl,

More information

Polymorphism Part 1 1

Polymorphism Part 1 1 Polymorphism Part 1 1 What is Polymorphism? Polymorphism refers to a programming language s ability to process objects differently depending on their data type or class. Number person real complex kid

More information

Midterm Exam 5 April 20, 2015

Midterm Exam 5 April 20, 2015 Midterm Exam 5 April 20, 2015 Name: Section 1: Multiple Choice Questions (24 pts total, 3 pts each) Q1: Which of the following is not a kind of inheritance in C++? a. public. b. private. c. static. d.

More information

C++ Mini-Course. Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion. C Rulez!

C++ Mini-Course. Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion. C Rulez! C++ Mini-Course Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion C Rulez! C++ Rulez! C++ Mini-Course Part 1: Mechanics C++ is a

More information

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value Paytm Programming Sample paper: 1) A copy constructor is called a. when an object is returned by value b. when an object is passed by value as an argument c. when compiler generates a temporary object

More information

CS3157: Advanced Programming. Outline

CS3157: Advanced Programming. Outline CS3157: Advanced Programming Lecture #12 Apr 3 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline Intro CPP Boring stuff: Language basics: identifiers, data types, operators, type conversions, branching

More information

CSE 333 Lecture smart pointers

CSE 333 Lecture smart pointers CSE 333 Lecture 14 -- smart pointers Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington Administrivia New exercise out today, due Wednesday morning Exam Friday

More information

COMS W3101 Programming Language: C++ (Fall 2016) Ramana Isukapalli

COMS W3101 Programming Language: C++ (Fall 2016) Ramana Isukapalli COMS W3101 Programming Language: C++ (Fall 2016) ramana@cs.columbia.edu Lecture-2 Overview of C C++ Functions Structures Pointers Design, difference with C Concepts of Object oriented Programming Concept

More information

Fast Introduction to Object Oriented Programming and C++

Fast Introduction to Object Oriented Programming and C++ Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming

More information

W3101: Programming Languages C++ Ramana Isukapalli

W3101: Programming Languages C++ Ramana Isukapalli Lecture-6 Operator overloading Namespaces Standard template library vector List Map Set Casting in C++ Operator Overloading Operator overloading On two objects of the same class, can we perform typical

More information

CS 251 INTERMEDIATE SOFTWARE DESIGN SPRING C ++ Basics Review part 2 Auto pointer, templates, STL algorithms

CS 251 INTERMEDIATE SOFTWARE DESIGN SPRING C ++ Basics Review part 2 Auto pointer, templates, STL algorithms CS 251 INTERMEDIATE SOFTWARE DESIGN SPRING 2011 C ++ Basics Review part 2 Auto pointer, templates, STL algorithms AUTO POINTER (AUTO_PTR) //Example showing a bad situation with naked pointers void MyFunction()

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February

More information

CS304 Object Oriented Programming Final Term

CS304 Object Oriented Programming Final Term 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing

More information

Lecture 7. Log into Linux New documents posted to course webpage

Lecture 7. Log into Linux New documents posted to course webpage Lecture 7 Log into Linux New documents posted to course webpage Coding style guideline; part of project grade is following this Homework 4, due on Monday; this is a written assignment Project 1, due next

More information

G52CPP C++ Programming Lecture 18

G52CPP C++ Programming Lecture 18 G52CPP C++ Programming Lecture 18 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Welcome Back 2 Last lecture Operator Overloading Strings and streams 3 Operator overloading - what to know

More information

1/29/2011 AUTO POINTER (AUTO_PTR) INTERMEDIATE SOFTWARE DESIGN SPRING delete ptr might not happen memory leak!

1/29/2011 AUTO POINTER (AUTO_PTR) INTERMEDIATE SOFTWARE DESIGN SPRING delete ptr might not happen memory leak! //Example showing a bad situation with naked pointers CS 251 INTERMEDIATE SOFTWARE DESIGN SPRING 2011 C ++ Basics Review part 2 Auto pointer, templates, STL algorithms void MyFunction() MyClass* ptr( new

More information

CSE 333 Lecture 9 - intro to C++

CSE 333 Lecture 9 - intro to C++ CSE 333 Lecture 9 - intro to C++ Hal Perkins Department of Computer Science & Engineering University of Washington Administrivia & Agenda Main topic: Intro to C++ But first: Some hints on HW2 Labs: The

More information

PIC 10A Objects/Classes

PIC 10A Objects/Classes PIC 10A Objects/Classes Ernest Ryu UCLA Mathematics Last edited: November 13, 2017 User-defined types In C++, we can define our own custom types. Object is synonymous to variable, and class is synonymous

More information

CS 11 C++ track: lecture 1

CS 11 C++ track: lecture 1 CS 11 C++ track: lecture 1 Administrivia Need a CS cluster account http://www.cs.caltech.edu/cgi-bin/ sysadmin/account_request.cgi Need to know UNIX (Linux) www.its.caltech.edu/its/facilities/labsclusters/

More information

Classes - 2. Data Processing Course, I. Hrivnacova, IPN Orsay

Classes - 2. Data Processing Course, I. Hrivnacova, IPN Orsay Classes - 2 Data Processing Course, I. Hrivnacova, IPN Orsay OOP, Classes Reminder Requirements for a Class Class Development Constructor Access Control Modifiers Getters, Setters Keyword this const Member

More information

CS102 C++ Exception Handling & Namespaces

CS102 C++ Exception Handling & Namespaces CS102 C++ Exception Handling & Namespaces Bill Cheng http://merlot.usc.edu/cs102-s12 1 Topics to cover C Structs (Ch 10) C++ Classes (Ch 11) Constructors Destructors Member functions Exception Handling

More information

Lecture 18 Tao Wang 1

Lecture 18 Tao Wang 1 Lecture 18 Tao Wang 1 Abstract Data Types in C++ (Classes) A procedural program consists of one or more algorithms that have been written in computerreadable language Input and display of program output

More information

Inheritance, and Polymorphism.

Inheritance, and Polymorphism. Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to

More information

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter

More information

Computer Science II CSci 1200 Lecture 24 C++ Inheritance and Polymorphism

Computer Science II CSci 1200 Lecture 24 C++ Inheritance and Polymorphism Computer Science II CSci 1200 Lecture 24 C++ Inheritance and Polymorphism Review from Lecture 23 cs2set operations: insert, destroy, printing, erase Tree height calculation illustrates the use of recursion

More information

Lecture 8: Object-Oriented Programming (OOP) EE3490E: Programming S1 2017/2018 Dr. Đào Trung Kiên Hanoi Univ. of Science and Technology

Lecture 8: Object-Oriented Programming (OOP) EE3490E: Programming S1 2017/2018 Dr. Đào Trung Kiên Hanoi Univ. of Science and Technology Lecture 8: Object-Oriented Programming (OOP) 1 Introduction to C++ 2 Overview Additional features compared to C: Object-oriented programming (OOP) Generic programming (template) Many other small changes

More information

A A B U n i v e r s i t y

A A B U n i v e r s i t y A A B U n i v e r s i t y Faculty of Computer Sciences O b j e c t O r i e n t e d P r o g r a m m i n g Week 4: Introduction to Classes and Objects Asst. Prof. Dr. M entor Hamiti mentor.hamiti@universitetiaab.com

More information

What does it mean by information hiding? What are the advantages of it? {5 Marks}

What does it mean by information hiding? What are the advantages of it? {5 Marks} SECTION ONE (COMPULSORY) Question #1 [30 Marks] a) Describe the main characteristics of object-oriented programming. {5 Marks Encapsulation the ability to define a new type and a set of operations on that

More information

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object CHAPTER 1 Introduction to Computers and Programming 1 1.1 Why Program? 1 1.2 Computer Systems: Hardware and Software 2 1.3 Programs and Programming Languages 8 1.4 What is a Program Made of? 14 1.5 Input,

More information

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year Object Oriented Programming Assistant Lecture Omar Al Khayat 2 nd Year Syllabus Overview of C++ Program Principles of object oriented programming including classes Introduction to Object-Oriented Paradigm:Structures

More information

A Tour of the C++ Programming Language

A Tour of the C++ Programming Language A Tour of the C++ Programming Language We already know C Everything that can be done with a computer, can be done in C Why should we learn another language? Newer languages provide a bigger toolbox Some

More information

G52CPP C++ Programming Lecture 17

G52CPP C++ Programming Lecture 17 G52CPP C++ Programming Lecture 17 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last Lecture Exceptions How to throw (return) different error values as exceptions And catch the exceptions

More information

Outline. 1 Function calls and parameter passing. 2 Pointers, arrays, and references. 5 Declarations, scope, and lifetimes 6 I/O

Outline. 1 Function calls and parameter passing. 2 Pointers, arrays, and references. 5 Declarations, scope, and lifetimes 6 I/O Outline EDAF30 Programming in C++ 2. Introduction. More on function calls and types. Sven Gestegård Robertz Computer Science, LTH 2018 1 Function calls and parameter passing 2 Pointers, arrays, and references

More information

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming

More information

G52CPP C++ Programming Lecture 20

G52CPP C++ Programming Lecture 20 G52CPP C++ Programming Lecture 20 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Wrapping up Slicing Problem Smart pointers More C++ things Exams 2 The slicing problem 3 Objects are not

More information

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING THROUGH C++ Practical: OOPS THROUGH C++ Subject Code: 1618407 PROGRAM NO.1 Programming exercise on executing a Basic C++

More information

CSE 333. Lecture 11 - constructor insanity. Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington

CSE 333. Lecture 11 - constructor insanity. Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington CSE 333 Lecture 11 - constructor insanity Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington Administrivia Exercises: - New exercise out today, due Monday morning

More information

Introduction to C++ Systems Programming

Introduction to C++ Systems Programming Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions

More information

the gamedesigninitiative at cornell university Lecture 7 C++ Overview

the gamedesigninitiative at cornell university Lecture 7 C++ Overview Lecture 7 Lecture 7 So You Think You Know C++ Most of you are experienced Java programmers Both in 2110 and several upper-level courses If you saw C++, was likely in a systems course Java was based on

More information

CS304 Object Oriented Programming

CS304 Object Oriented Programming 1 CS304 Object Oriented Programming 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes?

More information

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli COMS W3101 Programming Language: C++ (Fall 2015) ramana@cs.columbia.edu Lecture-2 Overview of C continued C character arrays Functions Structures Pointers C++ string class C++ Design, difference with C

More information

Course "Data Processing" Name: Master-1: Nuclear Energy Session /2018 Examen - Part A Page 1

Course Data Processing Name: Master-1: Nuclear Energy Session /2018 Examen - Part A Page 1 Examen - Part A Page 1 1. mydir directory contains three files: filea.txt fileb.txt filec.txt. How many files will be in the directory after performing the following operations: $ ls filea.txt fileb.txt

More information

G52CPP C++ Programming Lecture 7. Dr Jason Atkin

G52CPP C++ Programming Lecture 7. Dr Jason Atkin G52CPP C++ Programming Lecture 7 Dr Jason Atkin 1 This lecture classes (and C++ structs) Member functions inline functions 2 Last lecture: predict the sizes 3 #pragma pack(1) #include struct A

More information

Introduction to Programming session 24

Introduction to Programming session 24 Introduction to Programming session 24 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2010 These slides are created using Deitel sslides Sharif Universityof Technology Outlines Introduction

More information

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a. Intro to OOP - Object and class - The sequence to define and use a class in a program - How/when to use scope resolution operator - How/when to the dot operator - Should be able to write the prototype

More information

CSCI-1200 Computer Science II Fall 2006 Lecture 23 C++ Inheritance and Polymorphism

CSCI-1200 Computer Science II Fall 2006 Lecture 23 C++ Inheritance and Polymorphism CSCI-1200 Computer Science II Fall 2006 Lecture 23 C++ Inheritance and Polymorphism Review from Lecture 22 Added parent pointers to the TreeNode to implement increment and decrement operations on tree

More information

Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming Introduction to Object-Oriented Programming Objects and classes Abstract Data Types (ADT). Encapsulation OOP: Introduction 1 Pure Object-Oriented Languages Five rules [Source: Alan Kay]: Everything in

More information

Object Oriented Programming. Solved MCQs - Part 2

Object Oriented Programming. Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 It is possible to declare as a friend A member function A global function A class All of the above What

More information

Announcements. CSCI 334: Principles of Programming Languages. Lecture 18: C/C++ Announcements. Announcements. Instructor: Dan Barowy

Announcements. CSCI 334: Principles of Programming Languages. Lecture 18: C/C++ Announcements. Announcements. Instructor: Dan Barowy CSCI 334: Principles of Programming Languages Lecture 18: C/C++ Homework help session will be tomorrow from 7-9pm in Schow 030A instead of on Thursday. Instructor: Dan Barowy HW6 and HW7 solutions We only

More information

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

Classes. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT).

Classes. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT). UNITII Classes Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT). It s a User Defined Data-type. The Data declared in a Class are called Data- Members

More information

CS 162, Lecture 25: Exam II Review. 30 May 2018

CS 162, Lecture 25: Exam II Review. 30 May 2018 CS 162, Lecture 25: Exam II Review 30 May 2018 True or False Pointers to a base class may be assigned the address of a derived class object. In C++ polymorphism is very difficult to achieve unless you

More information

Object-Oriented Principles and Practice / C++

Object-Oriented Principles and Practice / C++ Object-Oriented Principles and Practice / C++ Alice E. Fischer September 26, 2016 OOPP / C++ Lecture 4... 1/33 Global vs. Class Static Parameters Move Semantics OOPP / C++ Lecture 4... 2/33 Global Functions

More information

Jayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT

Jayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT Two Mark Questions UNIT - I 1. DEFINE ENCAPSULATION. Encapsulation is the process of combining data and functions

More information

G52CPP C++ Programming Lecture 9

G52CPP C++ Programming Lecture 9 G52CPP C++ Programming Lecture 9 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last lecture const Constants, including pointers The C pre-processor And macros Compiling and linking And

More information