COP3330 Exam 2 Review – Myers Actual Updated Questions And Answers, Exams of Medicine

COP3330 Exam 2 Review – Myers Actual Updated Questions And Answers

Typology: Exams

2025/2026

Available from 01/11/2026

Ted.Bright
Ted.Bright 🇺🇸

5

(1)

7.3K documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COP3330 Exam 2 Review
Myers Actual Updated Questions And
Answers
1.
Four things every class
has
-constructor
-destructor
-copy constructor
- assignment operator (overload operator=)
2.
Assignment Operator
-Overload of operator=
-Invoked when something is assigned to object
-Declared format: Typename& operator=(const Typename &)
-makes deep copy similar to copy constructor
-needs to return *this(calling object) to enable cascading
DEEP COPY.
3.
Copy Constructor
-Declared Format: typename(const typename &)
-Invoked when a new copy of an object is created
-copys are made when:
1.
An object is declared and initialized to another objects value
2.
An object is passed or returned by value
DEEP COPY.
4.
how to declare a derived
class
Format:
class derivedname :: class basename
example:
class Sport --> class Football :: class Sport
{ {
} }
5.
Meaning of Protected
members declared as protected can be accessed by the class itself and
by derived classes only
6.
How to declare an array
of objects (not member
data)
pf3
pf4
pf5

Partial preview of the text

Download COP3330 Exam 2 Review – Myers Actual Updated Questions And Answers and more Exams Medicine in PDF only on Docsity!

COP3330 Exam 2 Review – Myers Actual Updated Questions And Answers

  1. Four things every class has - constructor - destructor - copy constructor - assignment operator (overload operator=)
  2. Assignment Operator - Overload of operator=
    • Invoked when something is assigned to object
    • Declared format: Typename& operator=(const Typename &)
    • makes deep copy similar to copy constructor
    • needs to return *this(calling object) to enable cascading DEEP COPY.
  3. Copy Constructor - Declared Format: typename(const typename &)
    • Invoked when a new copy of an object is created
    • copys are made when:
    1. An object is declared and initialized to another objects value
    2. An object is passed or returned by value DEEP COPY.
  4. how to declare a derived class Format: class derivedname :: class basename example: class Sport --> class Football :: class Sport { { } }
  5. Meaning of Protected members declared as protected can be accessed by the class itself and by derived classes only
  6. How to declare an array of objects (not member data)

[SIZE];ex: Fraction evens[10];

  1. What are the two differ- ent types of memory al- location?
  2. How do you create dy- namic space? (for alloca- tion during run-time) Static (compile-time) (before the program runs) and Dynamic (run-time) (after the program starts) With the keyword 'new'
  3. What ALWAYS follows the A type. keyword 'new' when cre- ating dynamic space?
  4. What does the keyword 'new' return?
  5. True or False: anything you can allocate statical- ly (variables, objects, ar- rays) you can also allo- cate dynamically.
  6. How do you initialize a dynamically-allocated object?
  7. How to remove dynami- The address of the newly allocated space. (it's a good idea to store this in a pointer) True. Either with the default constructor or by passing the appropriate para- meters to the object. f1 = new Fraction(1,2); Use the keyword 'delete' on the pointer to the dynamic space and it will cally allocated space (not de-allocate the target an array)
  8. How to remove a dynam- Use the keyword 'delete' followed by the bracket operator [] then the
  9. ically allocated array name of the array. delete [] evens;

What is the arrow opera- tor and how is it used?

  1. What are the four steps

It is similar to the dot operator but it works for pointers without having to de-reference() them. p->Show(); is equivalent to (p).Show(); The object that the pointer points to is what is operated on, the arrow operator just provides the shortcut.

  1. Create a new array with the new size using the keyword 'new' to re-sizing a dynamically 2. Copy the contents of the original array to the new array allocated array? 3. Deleted the original array
  2. Point the original array to the new array so that the original name remains with the new array
  3. How do you create an ar- Store a pointer that points to the array as member data and dynamically ray of dynamic size as member data of a class?
  4. If a pointer to a dynamic array is member data of a class, what should be done in the constructor with it?
  5. If you use dynamic al- location in a class, what should you do to be sure there are no memory leaks?
  6. True or False: It is a good idea to use dy- allocate the array later on Either the allocation can take place, or the pointer should be set to null until later use so that it points to a known location instead of a random location that could mess up the program later on. Specify to delete dynamic memory in the destructor of the class object False, if a member function needs to accomplish dynamic memory allocation, it would be a better idea to separate that task into another

What does it mean if a class has at least one pure virtual function?

  1. What does it mean if a class is abstract?
  2. What does polymor- phism mean? It means objects cannot be created from the class. An abstract class usually does not have the proper data to satisfy a semantic meaning and it rather serves as a category/placeholder for the child classes. ...