Day 6 Flashcards

1
Q

What is a class?

A

A blueprint written by a programmer to define what actions an object can perform

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an object?

A

an instance of the class when the program is running

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Constructor

A
called to initialize class data
same name as class
no parameters
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Destructor

A
  • if you see a banana peel ~ you know its a destructor

- uses free memory when the object leaves scope or with the delete keyword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Private

A
  • keyword describes section of info only used by class itself.
  • by default, all classes are private
  • (private means private! - no one else can see it!!)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Public

A
  • keyword that describes info that can be accessed from outside of class
  • like free wifi at starbucks ;P
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

behavior

A
  • function declared inside class body.
  • manipulate private class variables
  • *it’s a behavior to manipulate private parts **
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

this

A
  • if you see –> , the answer is THIS.
  • indicates the object itself and cannot be accessed outside of the class code definition.
  • commonly used with characteristics and methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Getters

Setters

A

-keyword is retrieve for getters and assign for setters

they retrieve/assign values to private characteristics

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What file contains the 2 classes to perform input and output?

A

include

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Input file stream

A

std::ifstream
its a class
question will likely ask for a “stream”
this is used when READING data from the file

be careful not to confuse this with fstream, read slowly on test

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Output file stream

A

std::ofstream
it’s a class
used when WRITING or appending data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

file mode : write mode

A

std::ios::out
truncates contents of existing file
DEFAULT ofstream

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

file mode: Append

A

std::ios::app

append to the end of the file if it already exists

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

file mode: Read mode

A

std::ios::in
cannot change contents of the file
DEFAULT for ifstream

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

file mode: read/write

A

std::ios::binary

read/write file as a stream of 0s and 1s rather than as text

17
Q

What do file modes do?

A

specify file pointer positions that change the postion of data access in a file.

18
Q

File output

A

ability to write data to a file

syntax: ofstream outfile;

19
Q

How do you test if the file opened correctly?

A

open()

20
Q

What do you do when the file is no longer necessary to free resources?

A

close()

21
Q

File input

A

ability to read data from a file.
getline will ALWAYS BE INPUT!!!!!
syntax: ifstream infile;