Object Oriented Programming

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/20

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

21 Terms

1
New cards

What’s the difference between structures and classes?

  • Struct members are public by default.

  • Class members are private by default. 

2
New cards

Are objects instances of classes? True or False?

True

3
New cards

What are the 3 different levels that members can have?

  • public-accessible from anywhere

  • protected-can only be accessed within the class and by child classes

  • private-accessible only inside the class

4
New cards

How does something become a friend of our class?

You use the keyword friend within the class.

5
New cards

What does the .(dot) operator do?

Used to access members of an object directly.

6
New cards

What does the arrow(→) operator do?

Used to access members through a pointer to an object.

7
New cards

Default constructor: When an why is it important to use it?

When it should be used: When you want objects to initialize with default values.

Why should it be used: When you have a constructor with no parameters

8
New cards

Explicit Constructor

When should it be used: When you want to make the conversion intentional.

Why should it be used: When you want to avoid implicit conversions in C++.

9
New cards

What is a destructor?

Special function to clean up when object is destroyed.

10
New cards

When is a destructor called?

Automatically when object goes out of scope or delete is used.

11
New cards

When does a destructor need to be written?

You manually allocate memory or acquire other resources in the class.

12
New cards

Canyou overload a destructor?

No – only one destructor allowed per class.

13
New cards

How do we make a member function constant?

you use the const keyword after the function's parameter list.

Example: int getValue() const

14
New cards

Why would we make a member function
constant?

not to modify the object’s member variables

15
New cards

What is an accessor?

Also known as a getter. It is used to access data.

16
New cards

What is a mutator?

Also known as a setter. It is used to modify private data.

17
New cards

What is a this pointer?

The this pointer refers to the current object on which the member function is being called.

18
New cards

Name 4 features of static members?

  • Belongs to a class

  • Accessed via ClassName::function

  • Does not have a “this” pointer

  • Memory is shared

19
New cards

Name 4 features of Non-static members?

  • Belongs to individual objects

  • Accessed via object.function()

  • Has a “this” pointer

  • Memory is unique per object

20
New cards

What is composition?

Composition in C++ means that a class is made up of one or more objects of other classes.

21
New cards

When building a uml diagram name what 3 things go in each box(box = classes)?

  • Name of the class in the 1st box

  • Data members in second box

  • Member functions in 3rd box (+public, -private, #protected)