CSE 2341 Honors Professor Mark Fontenot Southern Methodist University Note Set 07.

Slides:



Advertisements
Similar presentations
The C ++ Language BY Shery khan. The C++ Language Bjarne Stroupstrup, the language’s creator C++ was designed to provide Simula’s facilities for program.
Advertisements

Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
CS-1030 Dr. Mark L. Hornick 1 Constructors Copy Constructors.
CSE 1341 Honors Professor Mark Fontenot Southern Methodist University Note Set 17.
Week 8 Recap CSE 115 Spring Composite Revisited Once we create a composite object, it can itself refer to composites. Once we create a composite.
Syntax & terminology review While the following slides are not exactly what we did on the board (object diagrams are not shown here) they cover most of.
Switch Switch case statements are a substitute for long if statements that compare a variable to several "integral" values ("integral" values are simply.
Week 4 Recap CSE 115 Spring Formal Parameter Lists Comma-separated list of formal parameters Formal parameters are listed giving the type of the.
Templates CS-341 Dick Steflik. Reuse Templates allow us to get more mileage out of the classes we create by allowing the user to supply certain attributes.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
What is a class? a class definition is a blueprint to build objects its like you use the blueprint for a house to build many houses in the same way you.
CSE 250: Data Structures Week 3 January 28 – February 1, 2008.
Templates CS-240 Dick Steflik & DJ. Foreman. Reuse Templates allow us to get more mileage out of the classes we create by allowing the user to supply.
Classes. Class expanded concept of a data structure: instead of holding only data, it can hold both data and functions. An object is an instantiation.
IT PUTS THE ++ IN C++ Object Oriented Programming.
Multiple Choice Solutions True/False a c b e d   T F.
Templates CS212 & CS-240. Reuse Templates allow extending our classes Allows the user to supply certain attributes at compile time. Attributes specified.
Inheritance in C++ CS-1030 Dr. Mark L. Hornick.
CSE 1341 Honors Professor Mark Fontenot Southern Methodist University Note Set 12.
Recap, Test 1 prep, Composition and Inheritance. Dates Test 1 – 12 th of March Assignment 1 – 20 th of March.
Moving from C to Java. The Java Syntax We Know Java Types Some of the types we know and love are still there  Integer: byte, short, char, int, long.
Polymorphism, Inheritance Pt. 1 COMP 401, Fall 2014 Lecture 7 9/9/2014.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
CSE 2341 Honors Professor Mark Fontenot Southern Methodist University Note Set 03.
C# F 1 CSC 298 Object Oriented Programming (Part 1)
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures C++ Review Part-I.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 5.
CSE 1301 Lecture 5 Writing Classes Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
CSSE501 Object-Oriented Development. Chapter 4: Classes and Methods  Chapters 4 and 5 present two sides of OOP: Chapter 4 discusses the static, compile.
CS212: Object Oriented Analysis and Design Lecture 14: Reusing classes in C++
CPSC 252 Operator Overloading and Convert Constructors Page 1 Operator overloading We would like to assign an element to a vector or retrieve an element.
Applications Development
Object Oriented Programming (OOP) Lecture No. 11.
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
Introduction to Generics
CHAPTER # 2 Part 2 PROGRAMS AND DATA 1 st semster King Saud University College of Applied studies and Community Service CSC1101 By: Asma Alosaimi.
CSE 1341 Honors Note Set 05 Professor Mark Fontenot Southern Methodist University.
#include guards Practical session #2 Software Engineering
Views of Data Data – nouns of programming world the objects that are manipulated information that is processed Humans like to group information Classes,
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
CSE 1341 Honors Professor Mark Fontenot Southern Methodist University Note Set 17.
Chapter 3 Templates Saurav Karmakar Spring Objective In Chapter 3, we will discuss: The concept of a template Function templates Class templates.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Composition When one class contains an instance variable whose type is another class, this is called composition. Instead of inheritance, which is based.
Classes in C++ And comparison to Java CS-1030 Dr. Mark L. Hornick.
Functions Functions, locals, parameters, and separate compilation.
Overview Class Scope Review: Object parameters passed by value reference constant reference Friend function Overloading operator.
72 4/11/98 CSE 143 Abstract Data Types [Sections , ]
Chapter 7 Constructors and Other Tools Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
1 Data Structures CSCI 132, Spring 2014 Lecture 2 Classes and Abstract Data Types Read Ch Read Style Guide (see course webpage)
This In Java, the keyword this allows an object to refer to itself. Or, in other words, this refers to the current object – the object whose method or.
Copyright 2006 Pearson Addison-Wesley, 2008, 2012 Joey Paquet 1 Concordia University Department of Computer Science and Software Engineering SOEN6441 –
Java Generics. Lecture Objectives To understand the objective of generic programming To be able to implement generic classes and methods To know the limitations.
Defining Data Types in C++ Part 2: classes. Quick review of OOP Object: combination of: –data structures (describe object attributes) –functions (describe.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
SEG4110 – Advanced Software Design and Reengineering TOPIC I Introduction to C++ For those who know Java And OO Principles in General.
Chapter # 2 Part 2 Programs And data
Java Generics.
Agenda Warmup AP Exam Review: Litvin A2
Functions, locals, parameters, and separate compilation
Chapter 10 Thinking in Objects
Method Mark and Lyubo.
References, const and classes
Chapter # 2 Part 2 Programs And data
Institute of Petroloeum Technology, Gandhinagar
Object Oriented Programming (OOP) Lecture No. 11
CSCE-221 C++ Coding Standard/Guidelines
Corresponds with Chapter 5
Presentation transcript:

CSE 2341 Honors Professor Mark Fontenot Southern Methodist University Note Set 07

Class Details You can’t initialize data members in class interface class roster { private: int numStudents; int maxStudents = 30; char** names; public: roster(); //and so on }; Can’t do this.

Source Code Organization You have options – As you’ve been proceeding Interface:.h file Implementation:.cpp file Very common class roster { private: int numStudents; char ** names; public: roster(); }; roster::roster () { //constructor code } roster.h roster.cpp

Source Code Organization You have options – All in.h file but interface still separate from implementation class roster { private: int numStudents; char ** names; public: roster(); }; roster::roster() { //stuff } roster.h

Source Code Organization You have options – inline in the interface – method implementations actually appear in the class interface. class roster { private: int numStudents; char ** names; public: roster() { //constructor code here } int getNumStudents () { return numStudents; } }; roster.h

Constant Data Members and Initialization constant data members initialized using member initialization syntax class roster { private: int numStudents; const int maxStudents; char ** names; public: roster(int nums, int max); //and so on }; roster::roster(int nums, int max) { numStudents = nums; maxStudents = max; } What’s wrong here?

Constant Data Members and Initialization constant data members initialized using member initialization syntax class roster { private: int numStudents; const int maxStudents; char ** names; public: roster(int nums, int max); //and so on }; roster::roster(int nums, int max) : maxStudents(max) { numStudents = nums; maxStudents = max; } Executed before the object is fully created; const-ness has not attached yet to variables

Class Relationships Several types of relationships between two different classes Major types: – Composition one classis composed of other class objects and perhaps primitives – Inheritance one class inherits all of the data and functionality of another class

Composition An object can be made up of other objects class Computer { private: Motherboard mBoard; Processor proc; Ram ram; public: computer (); }; These aren’t primitives; they are object types

?