CSCE 240 Exam 3

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

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 12:58 PM on 4/16/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

18 Terms

1
New cards

If a class has a pointer data member, you usually need:

Destructor, Copy Constructor, Assignment Operator

2
New cards

Why do you need a destructor?

to free up dynamically allocated memory

3
New cards

Why do you need a copy constructor?

A copy constructor makes a deep copy so each object has its own memory and doesn't share the same pointer

4
New cards

Why do you need an assignment operator?

An assignment operator makes a deep copy so each object has its own memory and doesn't share the same pointer

5
New cards

What happens without a destructor?

A memory leak

6
New cards

What happens without a copy constructor?

two pointers with data members could point to the same location and could change both contents unintentionally

7
New cards

What does public mean?

can be accessed by member functions and objects

8
New cards

What does protected mean?

can be accessed by member functions (NOT objects)

9
New cards

Private

can be accessed only inside the class it is defined

10
New cards

What does inheritance do?

Inheritance allows a class to be defined as a new version of an existing class

11
New cards

When and why should you place a function, class variable, etc in a namespace?

You should place it when they share the same name to avoid naming conflicts

12
New cards

Explain the difference between composition and inheritance?

Composition is when there is a class inside of a class that can call on each other. Inheritance is when a parent class has a child class that uses the same functions and calls upon the parent class.

13
New cards

When should you make a virtual function?

You should make it virtual when its polymorphic

14
New cards

Polymorphic

means a function may behave differently depending on object type at runtime

15
New cards

What is the difference between a virtual function and a pure virtual function?

A virtual function is implemented for polymorphic functions. The difference is that it is implemented and can be instantiated. A pure virtual function is implemented set to 0.

16
New cards

What does instantiate mean?

means to create an object from a class

17
New cards

Abstract class

A class that has atleast one pure virtual function and can not be used to instantiate objectes

18
New cards

What three functions/operators should you write in your class if you have a pointer as a data member?

You need a destructor to free up dynamically allocated memory. You need a copy constructor and assignment operator to create deep copies to ensure each object has its own memory and doesn't share the same pointer