SCC111: weeks 11-15 Flashcards

(14 cards)

1
Q

what type of programming language is C++?

A

-procedural programming language

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

what is a procedural programming language?

A

-programs are executed in an order: sequentially

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

what are some key features of a procedural programming language?

A

-there is a well-defined starting point to the program
-code is broken down into manageable chunks (functions)
-variables are passed as parameters between functions

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

what is the benefit of using object orientated programming languages?

A

-encapsulates data
-variables belonging to an object are attributes
-functions belonging to an object are methods
-programmers can choose the visibility of data belonging to an object

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

how are classes defined in C++?

A

class Car{

};

//REMEMBER THE SEMICOLON

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

how would you define the class car with the variable colour and the method repaint?

A

class Car{
char* colour;
public:
void repaint(char* newColour);
};

void Car::repaint(char* newColour){
colour = newColour;
}

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

how would you create a new instance of a car class and call the repaint function on it?

A

Car myCar;

myCar.repaint((char*)”Red”);

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

how would you declare public and private methods and attributes?

A

class Car{
private:
int milesDriven = 0;
int getMilesDriven();
public:
char colour;
int repaint(char
newColour);
};

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

how is a class constructor written?

A

class Car{
public:
Car();
};
Car::Car(){
//initialisation code here
}

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

can classes in C have multiple constructors??

A

yus

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

how are constructors differentiated between?

A

-different parameters needed for each one

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

what is a destructor?

A

function that is invoked automatically when an object is being destroyed.

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

what is the syntax for a destructor?

A

class BankAccount{
//attributes and methods
//destructor:
~BankAccount();
};
BankAccount::~BankAccount(){
//destructor code
}

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