Opening Input/Output Files void openFiles ( ifstream& infile, ofstream& outfile) { char inFileName[40]; char outFileName[40]; cout<<"Enter the input file.

Slides:



Advertisements
Similar presentations
Chapter 11 Separate Compilation and Namespaces. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives Separate Compilation.
Advertisements

Copyright © 2002 Pearson Education, Inc. Slide 1.
Copyright © 2012 Pearson Education, Inc. Chapter 15: Inheritance, Polymorphism, and Virtual Functions.
OOP: Inheritance By: Lamiaa Said.
Chapter 1 OO using C++. Abstract Data Types Before we begin we should know how to accomplish the goal of the program We should know all the input and.
Inheritance and Composition (aka containment) Textbook Chapter –
Functions CS 308 – Data Structures. Function Definition Define function header and function body Value-returning functions return-data-type function-name(parameter.
Chapter 11 Separate Compilation and Namespaces Copyright © 2008 Pearson Addison-Wesley. All rights reserved.
Inheritance, Polymorphism, and Virtual Functions
Polymorphism. Lecture Objectives To understand the concept of polymorphism To understand the concept of static or early binding To understand the concept.
1 Chapter 14-2 Object- Oriented Software Development Dale/Weems.
Chapter 3 Interactivity and Expressions CSC 125 Introduction to C++ programming.
CLASSES AND DATA ABSTRACTION
Chapter 11: Inheritance and Composition. Objectives In this chapter, you will: – Learn about inheritance – Learn about derived and base classes – Redefine.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
1 Chapter 14 Object-Oriented Software Development Dale/Weems/Headington.
Core Java: Essential Features 08/05/2015 Kien Tran.
OOP and Dynamic Method Binding Chapter 9. Object Oriented Programming Skipping most of this chapter Focus on 9.4, Dynamic method binding – Polymorphism.
File I/O ifstreams and ofstreams Sections 11.1 &
Chapter 9 I/O Streams and Data Files
Parameters… Classes Cont Mrs. C. Furman October 13, 2008.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
File I/O 1 ifstreams and ofstreams Sections 11.1 & 11.2.
Abstraction CMPS Abstraction Abstraction mechanisms are techniques to deal with creating, understanding and managing complex systems Abstraction.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Stacks.
Chapter 11 Separate Compilation and Namespaces. Learning Objectives Separate Compilation –Encapsulation reviewed –Header and implementation files Namespaces.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
COP3502 Programming Fundamentals for CIS Majors 1 Instructor: Parisa Rashidi.
Vectors One-Dimensional Containers. Problem A file contains a sequence of names and scores: Ann92 Bob84 Chris89... Using OCD, design and implement a program.
1 More Operator Overloading Chapter Objectives You will be able to: Define and use an overloaded operator to output objects of your own classes.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 6 Functions.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 13: Inheritance and Composition.
Chapter 11: Inheritance and Composition. Introduction Two common ways to relate two classes in a meaningful way are: – Inheritance (“is-a” relationship)
11 Introduction to Object Oriented Programming (Continued) Cats.
CMSC 202 Polymorphism. 10/20102 Topics Binding (early and late) Upcasting and downcasting Extensibility The final modifier with  methods  classes.
CS 1430: Programming in C++ 1. File Input in VS Project Properties Debugging Command Arguments quiz8-1.out We want to know how to do it ourselves, right?
Inheritance - 3. Virtual Functions Functions defined as virtual are ones that the base expects its derived classes may redefine. Functions defined as.
Polymorphism & Virtual Functions 1. Objectives 2  Polymorphism in C++  Pointers to derived classes  Important point on inheritance  Introduction to.
Console Programs Console programs are programs that use text to communicate with the use and environment – printing text to screen, reading input from.
Defining Data Types in C++ Part 2: classes. Quick review of OOP Object: combination of: –data structures (describe object attributes) –functions (describe.
Learning Plan 6 Java Programming Intro to Object Oriented Programming.
2.4 Exceptions n Detects try { //code that may raise an exception and/or set some condition if (condition) throw exceptionName; //Freq. A string } n Handles.
1 Chapter 12 Classes and Abstraction. 2 Chapter 12 Topics Meaning of an Abstract Data Type Declaring and Using a class Data Type Using Separate Specification.
Chapter 12 Classes and Abstraction
CMIP5 Questionnaire Roadmap – beta
Chapter Structured Types, Data Abstraction and Classes
Polymorphism & Virtual Functions
Section 11.1 Class Variables and Methods
Object Oriented Analysis and Design
Separate Compilation and Namespaces
Introduction to Data Structures
Java Programming Language
Inheritance, Polymorphism, and Virtual Functions
CMSC 202 Lesson 22 Templates I.
when need to keep permanently
Text Files All the programs you've seen so far have one thing in common: Any data the program uses or calculates is lost when the program ends. In order.
Polymorphism CT1513.
Standard Input/Output Stream
Data Structures and Algorithms for Information Processing
CS150 Introduction to Computer Science 1
CS150 Introduction to Computer Science 1
Chapter 11: Inheritance and Composition
Chapter 14 Object-Oriented Software Development
Templates I CMSC 202.
What Is? function predefined, programmer-defined
Chapter 11 Class Inheritance
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Templates CMSC 202, Version 4/02.
Lecture 3 More on Flow Control, More on Functions,
Computer Science II for Majors
Presentation transcript:

Opening Input/Output Files void openFiles ( ifstream& infile, ofstream& outfile) { char inFileName[40]; char outFileName[40]; cout<<"Enter the input file name: "; cin>>inFileName; infile.open(inFileName); //open input file cout<<"Enter the output file name: "; cin>> outFileName; outfile.open(outFileName);//open out putfile }

#ifndef n To avoid including your.h files more than once, when using multiple files (gives you a redefinition link error), add the following to all you.h files #ifndef FILE_H #define FILE_H //code goes here #endif

Three important characteristics of OOP n 1. Encapsulation - see Section 2.1 n 2. Inheritance - hierarchy in which descendant class inherits data and operations from ancestor class n Example: ottoman End table furniture chable chairtable dinette

Three important characteristics of OOP n 3. Polymorphism - several operations with same name – binding time - time name/symbol bound to code/value – static binding - resolved at compiled time – dynamic binding - resolved at run time – operation overloading - static binding

Specifying Functions n Up to now Purpose/Receives/Returns n Text Book uses Pre- and Post-conditions n Pre-condition: describes what must be true about the state for the function to work correctly n Post-condition: describes what will be true about the state if the pre-conditions are met

Specifying Functions cont. n Precondition – discusses appropriate values for receives parameters and member data of object if it is a member function we are specifying n Post-condition – describes what the return variables values will be and what changes will be made to the object

Error Conditions Describe what preconditions will be checked by the function (might use try/catch)