Coding - practical 9 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is the ‘class’ keyword used for?

A
  1. Defining a class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What follows the class keyword?

A
  1. The name of the class (should always start with capital letter)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What comes after the class keyword

A

{ and the Public keyword - used to define parts of our class that are visible to other parts of the program

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

What comes after the public keyword?

A

A brace should always follow the class name, and the class definition ends with a closing brace and semicolon.

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

What are member variables?

A

Member variables are like normal variables except they define some property about our class.

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

How do you create an instance of your class variable?

A

Add it under shared variables

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

What is the dot operator used for?

A

To set or access a class’s member variables

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

What are class methods?

A

Class methods are functions that live inside a class definition and normally act upon the state of the class in someway.

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

What does a class method have access to?

A

A class method has access to all of a classes member variables, without needing to use the dot operator.

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

How do you add a class method?

A

To add a class method simply define a function within the class’s definition, underneath the public label, and before the ending brace.

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

What is a class?

A

A class in C++ is a user defined type or data structure that has data and functions (also called methods)

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

What are the labels that that we use inside our class to define visibility of methods and members?

A
  • Public: All other code can access the member variables and call the methods
  • Private: Only the class itself can use the member variables or methods.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly