lec 10: C++ Programming - taking classes further

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/38

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 2:34 AM on 4/10/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

39 Terms

1
New cards

What is inheritance in OOP?

A way to define a class in terms of another class.

2
New cards

Why is inheritance useful?

It helps organization, maintenance, code reuse, and implementation speed.

3
New cards

What is a base class?

The existing class being inherited from.

4
New cards

What is a derived class?

The new class that inherits from a base class.

5
New cards

What is another name for base class?

Superclass.

6
New cards

What is another name for derived class?

Subclass.

7
New cards

How do you declare a derived class in C++?

class Derived : access_specifier Base { … };

8
New cards

What access specifiers can be used in inheritance?

public, protected, private

9
New cards

What is the default inheritance access if omitted in a class derivation list?

private

10
New cards
11
New cards

Can a derived class inherit from more than one base class in C++?

Yes.

12
New cards

What is that called?

Multiple inheritance.

13
New cards

How do you write multiple inheritance?

By listing multiple base classes separated by commas after the colon.

14
New cards
15
New cards

What members can members of the same class access?

public, protected, and private

16
New cards

What members can members of a derived class access?

public and protected, but not private

17
New cards

What members can non-members access?

public only

18
New cards
19
New cards

What happens in public inheritance?

Inherited members keep the same access levels they had in the base class.

20
New cards

What happens in protected inheritance?

Base-class public members become protected in the derived class.

21
New cards

What happens in private inheritance?

Inherited members become private in the derived class.

22
New cards

Which inheritance style does the slide deck generally recommend for most use cases?

public inheritance

23
New cards
24
New cards

If a base class member is protected, can a derived class access it directly?

Yes.

25
New cards

If a base class member is private, can a derived class access it directly?

No.

26
New cards

If a base class member is private, how should a derived class usually work with it?

Through public/protected methods such as setters/getters.

27
New cards
28
New cards

In inheritance, which constructor runs first: base or derived?

Base constructor first.

29
New cards

In inheritance, which destructor runs last: base or derived?

Base destructor last.

30
New cards

If you do not explicitly specify which base constructor to call, which one is used?

The default constructor.

31
New cards

How do you explicitly choose a base constructor from a derived constructor?

With an initializer list, like Child(int x) : Parent(x) { }

32
New cards
33
New cards

What is a friend of a class?

A function or class given access to the class’s private/protected members.

34
New cards

Is friendship reciprocal by default?

No.

35
New cards

Is friendship transitive by default?

No.

36
New cards

What is a friend function?

A non-member function declared with friend that can access private/protected members.

37
New cards

Is a friend function actually a member of the class?

No.

38
New cards

What is a friend class?

A class whose members can access another class’s private/protected members.

39
New cards

Why might a forward declaration be needed with friend classes?

To deal with circular dependencies between classes.