c++ Flashcards

1
Q

What two lines usually precede every source file?

A
#include 
using namespace std;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

does an array in c++ have a length field like java?

A

No

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

What does the header file contain in c++?

A

class/function declarations

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

What should member variables start with?

A

m_

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

When is a destructor executed?

A

When the instance of the constructor is overwritten

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

What is inlining in c++ and in java?

A

declaring body and header of a function on the same line

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

When overloading a function does the @overload need to precede the declaration?

A

No

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

What type is null?

A

int

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

What is the syntax for default parameters?

A

type function_name (type a, type b = value)

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

If B is a superclass of A, what is the syntax for inheritance?

A

class B : public A

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

Can a class inherit more than one class?

A

Yes

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

If the subclass method has to overwrite from the superclass what keyword must be used?

A

virtual

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

In the superclass, how is an abstract method defined?

A

virtual type name() = 0;

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

What is a pointer?

A

a memory address

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

How is a pointer defined?

A

int* name;

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

What are the 4 pillars of object oriented programming?

A
  1. ) Encapsulation
  2. ) Data hiding
  3. ) Inheritance
  4. ) Polymorphism
17
Q

What is a trigraph?

A

A series of 3 symbols that represent compiler recognized symbols

18
Q

Are trigraphs supported by every comiler?

A

No

19
Q

What do enumeration types do?

A

Allow for custom types

20
Q

What are the two ways to define a constant in c++?

A

using the #define or const keyword

21
Q

What are the three type qualifiers in c++?

A

const, volatile, restrict

22
Q

What are the differences between the auto and register storage classes?

A

It is given a small memory allocation, but does not have a memory address

23
Q

What variables should be put in the register?

A

variables that need to be accessed quickly, such as counters

24
Q

What is special about variables with the extern storage class?

A

They are visible to external source files

25
Q

What is the traditional way for writing an infinite loop?

A

for(;;)

26
Q

If Exp1 is false for Exp1 ? Exp2 : Exp3, what expression is executed?

A

Exp3

27
Q

What is the difference between a struct and a class in c++?

A

A struct has members that are public by default for instances and derived classes