DOC PREVIEW
Purdue ECE 462 - File Read and Write

This preview shows page 1-2-3-4-5-39-40-41-42-43-44-78-79-80-81-82 out of 82 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 82 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

File Read and WriteSave and Open File in JavaSave and Open File in C++Valgrind and QtSuppress False Warnings andErrors from ValgrindDeclaration, Definition,and InitializationJava and C++Default Initializationno-arg constructorArray in C++Array in JavaYHL File 1ECE 462Object-Oriented Programmingusing C++ and JavaFile Read and WriteYung-Hsiang [email protected] File 2Save and Open File in JavaYHL File 3YHL File 4YHL File 5YHL File 6YHL File 7YHL File 8YHL File 9YHL File 10YHL File 11YHL File 12YHL File 13YHL File 14YHL File 15YHL File 16YHL File 17YHL File 18YHL File 19YHL File 20YHL File 21YHL File 22YHL File 23YHL File 24YHL File 25YHL File 26To Do• handle Edit-Undo⇒ record the latest change for undo• check whether the current text has been saved before File-New or File-Open⇒ keep a flag that indicates the content in the text area has changed but not saved; reset the flag after the file has been savedYHL File 27Save and Open File in C++Modified from theMain Window - Menus example in Qt/home/shay/a/sfwtools/public/qt4.3.0/examplesYHL File 28YHL File 29YHL File 30YHL File 31YHL File 32YHL File 33YHL File 34YHL File 35YHL File 36YHL File 37YHL File 38YHL File 39YHL File 40YHL File 41YHL File 42YHL File 43different from the exampleYHL File 44YHL File 45YHL File 46YHL File 47YHL File 48YHL File 49YHL File 50Valgrind and QtYHL File 51The program doesn't do anything.YHL File 52YHL File 53report problemseven though theprogram doesn'tdo anything.YHL File 54memory leakYHL File 55memory leak in MainWindow::MainWindowYHL File 56Qt and ValgrindYHL File 57valgrind does not check index out of array boundYHL File 58Suppress False Warnings and Errors from ValgrindIf you do not want to see "errors"about the libraries.YHL File 59YHL File 60YHL File 61Self TestYHL Declaration, Definition, and Initialization 1ECE 462Object-Oriented Programmingusing C++ and JavaDeclaration, Definition, and InitializationYung-Hsiang [email protected] Declaration, Definition, and Initialization 2Declaration, Definition, Initialization• declaration: inform the compiler the existence of an identifier (variable name, function name, class name ...)• definition: for variable, memory is allocated; for function, code is written• initialization: assign (default) value to variable• You should always initialize all variables and objects. Uninitialized values are a common source for errors.• Never leave anything uninitialized.YHL Declaration, Definition, and Initialization 3Declaration and Definitionint xvar; // definitionint xvar = 4; // definition and initializationextern int xvar; // declaration only in C++// defined somewhere elseclass Student; // declaration in C++class Student { // definitionint s_id;int s_year;};double func(int, float); // declarationdouble func(int xval, float yval){ return (exp(yval) * xval); } // definitionYHL Declaration, Definition, and Initialization 4Declaration before Definitionclass Student; // declaration in C++class Teacher {list<Student*> t_stud; // list<Student> causes error since// Student has not been defined};class Student {int s_id;};C ++ initialization: • primitive types: default value•objects: if no-arg constructor providedYHL Declaration, Definition, and Initialization 5Java and C++declare, define, and initialize using no-arg constructorAClass anobj; // declare// nullsameint x = 6; // declare, define, and// initialize to 6declare and defineint x; // declare class AClass; // declarationunnecessaryAClass * objptr = new AClass(...); // sameAClass anobj = new AClass(...)// declare, define, initializedAClass * objptr; // declaredsyntax errorC++JavaYHL Declaration, Definition, and Initialization 6Default Initializationnot applicable-object pointernullobjectno-arg constructorobject0.0ffloat0.0float0int0int\u0000char'\0'charfalsebooleanfalseboolJavaC++YHL Declaration, Definition, and Initialization 7no-arg constructorclass ClassName {public:ClassName() {// no-arg constructor}}• In C++, if no constructor is provided, the compiler will automatically provide a no-arg constructor (probably not what you want)• If any programmer-provided constructor exists, the compiler does not add any constructor.YHL Declaration, Definition, and Initialization 8no-arg constructorC++YHL Declaration, Definition, and Initialization 9JavaYHL Declaration, Definition, and Initialization 10C++YHL Declaration, Definition, and Initialization 11JavaYHL Declaration, Definition, and Initialization 12C++YHL Declaration, Definition, and Initialization 13JavaYHL Declaration, Definition, and Initialization 14YHL Declaration, Definition, and Initialization 15YHL Declaration, Definition, and Initialization 16Array in C++YHL Declaration, Definition, and Initialization 17YHL Declaration, Definition, and Initialization 18Array in JavaYHL Declaration, Definition, and Initialization 19YHL Declaration, Definition, and Initialization 20YHL Declaration, Definition, and Initialization 21Self


View Full Document

Purdue ECE 462 - File Read and Write

Download File Read and Write
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view File Read and Write and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view File Read and Write 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?