C++ Chapter 6 I/O Streams as an Intro to Objects & Classes

Card Set Information

Author:
senator77
ID:
139293
Filename:
C++ Chapter 6 I/O Streams as an Intro to Objects & Classes
Updated:
2012-03-05 15:05:48
Tags:
streams basic member function
Folders:

Description:
C++ Chapter 6 I/O Streams as an Intro to Objects & Classes
Show Answers:

Home > Flashcards > Print Preview

The flashcards below were created by user senator77 on FreezingBlue Flashcards. What would you like to do?


  1. A stream of type ifstream can be connected to a file with a call to the member function open. Your program can then take input from that file.Wikipedia: A take is a single continuous recorded performance.
  2. A stream of type ofstream can be connected to a file with a call to the member function open. Your program can then send output to the file.
  3. You should use the member function fail to check whether a call to open was successful.
  4. An object is a variable that has functions associated with it. These functions are called member functions.
  5. A class is a type whose variables are objects. A stream is an example of an object. The types ifstream and ofstream are examples of classes.
  6. The following is the syntax you use when you write a call to a member function of an object:
    Calling_Object.Member_Function_Name(Argument_List);
    An example with the stream cout as the calling object and precision as the member function is:
    cout.precision(2);
  7. Stream member functions, such as width, setf, and precision, can be used to format output. These output functions work the same for the stream cout, which is connected to the screen, and for output streams connected to files.
  8. Every input stream has a member function named get that can be used to read one character of input. The member function get does not skip over whitespace.
  9. Every output stream has a member function named put that can be used to write one character to the output stream.
  10. The member function eof can be used to test for when a program has reached the end of an input file, which works well for text processing.
  11. A function may have formal parameters of stream type but they must be call-by-reference parameters.
  12. The type ifstream can be used for an input-file stream, and the type ofstream can be used for an output-file stream.
  13. If you use istream as the type for an input-stream parameter, then the argument corresponding to that formal parameter can be either the stream cin or an input-file stream of type ifstream.
  14. If you use ostream as the type for an output stream parameter, then the argument corresponding to that formal parameter can be either the stream cout or an output-file stream of type ofstream.
  15. A stream is a flow of data. If the flow in into your program, the stream is called an input stream. If the flow is out of your program, the stream is called an output stream.
  16. When your program takes input from a file, it is said to be reading from the file; when your program sends output to a file, it is said to be writing to the file.
  17. A stream is a special kind of variable known as an object.
  18. You cannot use a stream variable in an assignment statement the way that you can use a variable of type int or char.
  19. The type for input-file stream variables is named ifstream (for "input-file stream").
  20. The type for output-file stream variables is named ofstream (for "output-file stream").
  21. The types ifstream and ofstream are defined in the library with the header file fstream, and so any program that declares stream variables must contain the following directives:
    #include <fstream>
    using namespace std;
  22. Stream variables must each be connected to a file. This is called opening the file and is done with a function named open.
  23. A class is a data type that has data (variables and values) as well as functions associated with it.
  24. The data and functions associated with a class are referred to as members of the class.
  25. Variables declared using a class as the data type are called objects.
  26. Sequential file processing is the processing of records in the order they are stored in the file.
  27. Use a while loop for file processing of empty files.
  28. When an object is declared using a class, a special function called a constructor is automatically called.
  29. Programmers use constructors to initialize variables that are members of the class.
  30. Constructors can also be overloaded to give programmers options when declaring objects.
  31. Default constructor takes no parameters:
    ifstream inFile;
    inFile.open(“infile.txt”);

    Overloaded constructor takes parameters:
    ifstream inFile (“infile.txt”);
  32. A flag is a term used with variables that can have two possible values.
    On or off
    0 or 1
    Y or N
    True or false
  33. To get one character including white space use get.
    cin.get(char);
  34. To get entire line up to the newline use getline.
    cin.getline(char, intSize);
  35. To put out one character use put.
    cout.put(char);
  36. The switch statement is an alternative to if-else statements for handling cases.
  37. The valid types for the controlling expression are:
    –bool
    –int
    –char
    –enum
  38. The break statement is used to end a sequence of statements in a switch statement.
  39. When the break statement is executed in a loop, the loop statement ends immediately and execution continues with the statement following the loop.

What would you like to do?

Home > Flashcards > Print Preview