CS Week 4- Classes ll Flashcards

1
Q

test bench

A

a program whose job is to thoroughly test another program (or portion) via a series of input/output checks (test cases)

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

test cases

A

a series of input/output checks

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

unit testing

A

to create and run a rest bench for a specific item like a function or a class

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

some features of a good test bench

A

–Automatically checks(only fails printed → test.GetNum() != 100)
–Independent test cases
–100% coverage - every line of code is excited
—Include border cases

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

Regression testing

A

to retest an item like a class anytime that item is changed

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

regressed

A

If previous passed cases fail

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

why should a test bench be maintained along with the item

A

to be usable for regression testing

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

erroneous unit tests

A

may fail even if the code being tested is correct

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

operator overloading

A

built-in operators to operate on programmer-defined objects

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

overload +

A

Create a member function named operator+

pass in an argument (literally anything but better an object)

create a new objects

add the sub items

return the object

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

overload the + multiple times

A

as long as each involves different types of parameters

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

overload ==

A

create a member function named operator==

return a bool

take in 2 const reference parameters

compare the corresponding items in the return statement

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

overload the < operator

A

return a bool

pass in 2 const reference parameters

if the lhs is < the rhs

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

overloading all equality and relational operators

A

1st overload the == and < and use these for the rest of the

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

overload the !

A

return a bool

pass in 2 const reference parameters

return !(lhs==rhs)

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

overload >

A

return a bool

pass in 2 const reference parameters

return rhs < lhs

17
Q

overload <=

A

return a bool

pass in 2 const reference parameters

return !(lhs>rhs)

18
Q

overload >=

A

return a bool

pass in 2 const reference parameters

return !(lhs<rhs)

19
Q

using sort() function

A

include <algorithm></algorithm>

overload the < operator for the defined class

call sort()
sort(v.begin(), v.end());

20
Q

overload the «

A

into a buffer of wanting to output all the subitems of a class

21
Q

overload the&raquo_space;

A

into a buffer of wanting to input into all the subitems of a class

22
Q

why use “friend”

A

can see the sub items of the class

only use the friend in the declaration not definition

23
Q

in what order to include files in main

A

alphabetical order
<> then “”

24
Q

in what order to include files in implementation file

A

”” first

25
Card.cpp vs Card.h
cpp - how it looks - the declarations include where? .h - header - how it works, definitions include where?
26
what to use so that you only include a file once
hashsymbol pragma once
27
what are the only files that will be included
.h
28
preprocessor
a tool that scans the file from top to bottom looking for any lines that begin with #
29
what does "" and <> tell the preprocessor
"" - same folder directory as the including file <>- look in the system's standard library folder/directory
30
header file guards
preprocessor directives that cause the compiler to only include the contents of the header file once hash ifndef FILENAME_H hash define FILENAME_H //contents hash endif
31
single step compilation
all source files are compiled at the same time to create the executable g++ main.cpp filename.cpp
32
modular compilation
each source file is independently compiled into an object file g++ main.o filename.o
33
object file
contains machine instructions for the compiled code along with placeholders, often referred to as references, for calls to functions or accesses to variables or classes defined in other source files
34
linker
will create the final executable by linking together the object files and libraries
35
define directive
hash define MACROIDENTIFIER replacement - instructs the processor to replace any occurrence of MACROIDENTIFEIR in the subsequent program code by the replacement test
36
name conflict
occurs when 2 or more items like variables, classes, or functions have the same name
37
namespace
defines a region(or scope) used to prevent name conflicts in main fileName :: classname in .h file namespace fileName { class className{ ... }; }
38
std
standard namespace
39
look over lecture notes