Const Parameters & In Line Functions 04/15/11. Next Time  Quiz, Monday, 04/18/11  Over 5.2 and 5.3 void functions pass-by-reference  Read 7.1 about.

Slides:



Advertisements
Similar presentations
Engineering Problem Solving With C++ An Object Based Approach Additional Topics Chapter 10 Programming with Classes.
Advertisements

Operator overloading redefine the operations of operators
Lesson 13 Introduction to Classes CS1 Lesson Introduction to Classes1.
Chapter 6 Advanced Function Features Pass by Value Pass by Reference Const parameters Overloaded functions.
CMSC 202, Version 2/02 1 Operator Overloading Strong Suggestion: Go over the Array class example in Section 8.8 of your text. (You may ignore the Array.
C++ Classes & Data Abstraction
Friend Functions 04/12/10. Today  Use reference parameters when passing an object.  Use friend functions with a class.
Constructors 11/10/10. Today  Use constructors to initialize objects.  Use const to protect data members.
CS-212 Classes (cont) Dick Steflik. Member functions Member functions of a class include – getters used to retrieve state data – setters used to set state.
Classes. What is a class? Data and the functions (methods) that operate on that data – collectively called members –Example: bank account class Provide.
C++ data types. Structs vs. Classes C++ Classes.
CSE 250: Data Structures Week 3 January 28 – February 1, 2008.
1 Review: Two Programming Paradigms Structural (Procedural) Object-Oriented PROGRAM PROGRAM FUNCTION OBJECT Operations Data OBJECT Operations Data OBJECT.
More Classes in C++ Bryce Boe 2012/08/20 CS32, Summer 2012 B.
CSE 333 – SECTION 4. Overview Pointers vs. references Const Classes, constructors, new, delete, etc. More operator overloading.
1 Classes- Inheritance Multiple Inheritance It is possible to derive a new class from more than one base class. This is called Multiple Inheritance. Under.
Chapter 8 Friends and Overloaded Operators. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. Slide 2 Overview Friend Function (8.1) Overloading.
CS212: Object Oriented Analysis and Design Lecture 6: Friends, Constructor and destructors.
Chapter 8. About the Midterm Exam.. Exam on March 12 Monday (Tentatively) Review on March 7 Wednesday Cover from Chapter 6 Grades will be out before spring.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 24P. 1Winter Quarter C++ Lecture 24.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Introduction To Classes Chapter Procedural And Object Oriented Programming Procedural programming focuses on the process/actions that occur in a.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13: Introduction to Classes.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
P Improvements - Constructor p Parameter passing Constructors Problem Solving With C++
Object-Oriented Programming. Procedural Programming All algorithms in a program are performed with functions and data can be viewed and changed directly.
Chapter 15 C++ Function By C. Shing ITEC Dept Radford University.
Object-Based Programming Mostly Review. Objects Review what is object? class? member variables? member functions? public members? private members? friend.
Copyright © 2002 W. A. Tucker1 Chapter 10 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Chapter 3 Introduction to Classes and Objects Definitions Examples.
© 2007 Lawrenceville Press Slide 1 Chapter 8 Objects  A variable of a data type that is a class. Also called an instance of a class.  Stores data  Can.
EGR 2261 Unit 11 Classes and Data Abstraction  Read Malik, Chapter 10.  Homework #11 and Lab #11 due next week.  Quiz next week.
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
Chapter 11 Friends and Overloaded Operators. Introduction to function equal // Date.h #ifndef _DATE_H_ #define _DATE_H_ class CDate { public: CDate();
Data Structures Using C++1 Chapter 3 Pointers and Array-Based Lists.
1 More Operator Overloading Chapter Objectives You will be able to: Define and use an overloaded operator to output objects of your own classes.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter 9 Objects and Classes.
Structures Revisited what is an aggregate construct? What aggregate constructs have we studied? what is a structure? what is the keyword to define a structure?
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Today: –Review declaration, implementation, simple class structure. –Add an exception class and show.
Object-Oriented Programming in C++ Lecture 4 Constants References Operator overloading.
Object-Oriented Programming (OOP) What we did was: (Procedural Programming) a logical procedure that takes input data, processes it, and produces output.
Objects with Functions and Arrays. Objects can be Passed Class defines type – Can use as type of function or parameter.
Overview Class Scope Review: Object parameters passed by value reference constant reference Friend function Overloading operator.
Introduction to Classes in C++ Instructor - Andrew S. O’Fallon CptS 122 Washington State University.
Chapter 7 Constructors and Other Tools Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
Inheritance in C++ Bryce Boe 2012/08/28 CS32, Summer 2012 B.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 13: Introduction to Classes.
Mr H Kandjimi 2016/01/03Mr Kandjimi1 Week 3 –Modularity in C++
Object-Oriented Programming Review 1. Object-Oriented Programming Object-Oriented Programming languages vary but generally all support the following features:
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Copyright © 2002 Pearson Education, Inc. Slide 1.
Copyright © 2002 Pearson Education, Inc. Slide 1.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Pointer to an Object Can define a pointer to an object:
Procedural and Object-Oriented Programming
Structures Revisited what is an aggregate construct? What aggregate constructs have we studied? what is a structure? what is the keyword to define a structure?
Haidong Xue Summer 2011, at GSU
A First C++ Class – a Circle
Overloading the << operator
References, const and classes
Introduction to Objects & Classes
JAVA CLASSES.
NAME 436.
C++ Programming CLASS This pointer Static Class Friend Class
const A& B::blah (const C& c) const {...} Passed in a reference to a constant object ‘c’  ‘c’ cannot be modified in the function const A& B::blah.
Overloading the << operator
C++ data types.
Lecture 8 Object Oriented Programming (OOP)
Presentation transcript:

Const Parameters & In Line Functions 04/15/11

Next Time  Quiz, Monday, 04/18/11  Over 5.2 and 5.3 void functions pass-by-reference  Read 7.1 about arrays

Pass Objects By-reference  More efficient  Opens possibility of changing Object  const in front to protect  point1.cpp void reflection_of(const Point &C, double v_axis);

Inline Function  Can give the function definition within the class definition.  Point class on next slide has in-line functions. One of them is the default constructor.

Constant Function  Member function that promises not to change any of the object's data members.  Add const after prototype double get_degrees( ) const;  tconstr.cpp  Should rise() or input_T() be const?

Circle Example  Write a class declaration for a class called Circle with a private data member called radius. Write an accessor function for the radius. Write a constructor to initialize the radius and a default constructor. Write a member function, findArea(), to find the area of the Circle.

Design the Class  Attributes?  Behaviors?

Next Time  Read 6.3 & 6.4  friend functions and overloaded operators