Quiz 1
Project 2 -- Umm....
Midterm -- Reminder July 2
Syllabus updated
CS151 -- Shawn Stoffer
IOStreams
#include <iostream>
istream cin;
ostream cout, cerr;
IOStreams
Operators:>> (istream), << (ostream)
IOStreams
Member functions:char get();
friend int getline(istream cin, string whereToPut);
IOStreams
#include <fstream>
ifstream fin;
ofstream fout;open member function: fin.open("filename");
close member function: fout.close("filename");
Classes
class Keyword
- defines a class
- class className { classBody };
Classes
class className { classBody };
className
- What is this new type's name?
Classes
class className {
public:
classBody
};
classBody
- several keywords
- public:
Classes
class className {
private:
classBody
};
classBody
- several keywords
- private:
Classes
class className {
protected:
classBody
};
classBody
- several keywords
- protected:
Classes
class className {
className();
classBody
};
classBody
- several keywords
- className
Classes
class className { classBody };
classBody
- member functions (methods)
- functions which are 'within' a class, and must be accessed using the . notation, which is read as within, though read from left to right...
Classes
Reading Code:
- myClass t;
t.move();- Declare a variable (and call it 't') which is of the type myClass
- Then, call the function ( '()' ) move ('move'), which is within ( '.' ) the variable t ( 't' ).
Classes
Member variables
- Usually declared within the private section of the class
- may be any type currently defined in C++, or a type that you have already defined (another class, etc..)
- may be as many as you wish...
Classes
Member functions
- May use all the member variables of the class, whether they are private or not, as though they were global variables.