COP3330 FINAL EXAM

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

what must be included in the header when wanting to use a class template in other files

#include "someclass.hpp" NOT cpp

the ________ operator is used to get the address of a variable

&

The _______ operator is used to dereference a pointer

*

data structures vs. design patterns

- design patterns are not constrained by language assuming that your language is completed and object oriented - data structures are constrained

what are the common data structures we talked about?

-stacks -queues -vector -linked list -hashSet / HashMap / Dictionary

linked list

Each object contains a pointer to the NEXT object in the list

given a class called MyClass, what would create an instance of MyClass on the heap?

MyClass* object = new MyClass;

instantiate the following class with the primitive type double: template < class T > class SimpleList{};

SimpleList < double > NameOfNewInstance;

singleton pattern

a class that may only be instantiated once after initial construction, any subsequent construction will result in obtaining a reference to the originally constructed instance

hashset

a list data structure that ENSURES UNIQUENESS Have to contain unique values

A class with at least one purely virtual function is referred to as:

abstract

__________ represents a "has a" relationship between two classes in object-oriented programming

aggregation

function templates

can be used to make the function use a variety of data types always comes at the very beginning of any function or class definition template <typename T> T could be int, double, float, etc.

How to declare an appropriate storage for a list of resizable c-style strings, called myString?

char** myString;

boilerplate code

code that ties everything together with repetitive patterns typically copied and pasted everywhere - want to minimize this

Which of the following is not an automatic in C++?: -default constructor -destructor -deep copy constructor -shallow copy assignment

deep copy constructor

how would you deallocate heap space associated with a dynamically allocated array named myArray

delete [] myArray;

which of the following deallocates heap space associated with a dynamically allocated OBJECT called myObject?

delete myObject; //you're deleting an object, not an array

data structures or abstract data types

encapsulations for the manipulation and (even temporary) storage of data

The keyword _____ restricts a conversion constructor from being called implicitly

explicit

true or false, a class template can only contain a single template function

false

true or false, a constructor cannot be implicitly called on an abstract class

false

true or false, a derived class can access any of its base class' private data and function members

false

true or false, derived classes must have destructors

false

true or false, for an array to be resizable, it must be stored on the stack

false

true or false, in either a function or a class template, the indentifier T can be used for more than one type within the same template

false

true or false, objects are templates for classes

false

true or false, statically allocated variables assigned to a dynamically allocated list will not fall out of scope until the array is deallocated

false

true or false, statically allocated variables must be deleted with the "delete" keyword before they fall out of scope

false

true or false, the definition of a friend function requires the use of the scope resolution operator

false

true or false, the delete keyword can be used on an unallocated address in heap space

false

true or false, the expression delete [] myArray deallocates both the pointers stored in myArray and myArray itself

false

true or false, typically derived classes are more generalized than base classes

false, the other way around

true or false, the expression *myPtr returns the address myPtr is stored at

false, value

queues

first in first out (FIFO) operations: enqueue - add item to the end of the line dequeue - remove item from the BEGINNING of the line

stacks

first in last out operations: push: adds something to the stack pop: removes the LAST item in the stack

Classes encapsulate two types of members: data members that define state and ______ members that define the behavior of a class

function

hashmap and dictionary

hashmaps, which are also called dictionaries, are like hashsets except the contan a unique KEY but DON'T have to contain a unique value

A(n) ______ is used to set constant data members of a class

initialization list

vector

list of items that allows random access, provides: - resizing / DMA - boundary checking Advantages - random access is easy Disadvantages - insertion and deletion is slow because you may have to shift array elements around

design patterns

methodologies for building code that solves common problems

function ____ occurs when two or more functions have the same name and return type but take in different parameters

overloading

Function ____ occurs when a derived class implements the same function as its base class

overriding

the keyword _____ restricts access to data and function members of a class to that class only

private

The ____ stores statically allocated memory in a C++ program

stack

declare a class template called myClass

template < class T > class myClass {};

singleton implementation

the constructor must be private the singleton class should have a static data member of the same type a public getter method then checks to see if initialization has ever happened before if initialization isn't initialized, the static data member is constructed and returned. if it has, the already constructed data member is returned

the rule of ______ is used to ensure that memory management for a user defined type is consistent with that for built-in types and helps avoid segmentation faults when consuming that user defined type

three

true or false in C++, classes can have an arbitrary number of parent (i.e. base) classes

true

true or false, a constructor cannot be explicitly called on an abstract class

true

true or false, a copy constructor should be implemented when a class uses DMA

true

true or false, a derived class must implement a purely virtual function

true

true or false, an abstract class can contain virtual functions that are not purely virtual

true

true or false, base classes can have copy constructors

true

true or false, copy constructors must take in their parameters in by reference

true

true or false, copy constructors should always take in a parameter by reference

true

true or false, multiple class definitions can be put into a single header file

true

true or false, the new keyword returns a pointer to safe heap space

true

true or false, when declared as a virtual function, myPtr->myFunction() will bind to the most derived class' implementation

true

true or false, when working with a dynamically allocated list of dynamically allocated objects in C++, you must clear each individual object instance AND the list that originally contained those references

true

true or false, a pointer of a base class type can reference a derived class type

true, polymorphism

true or false, statically allocated objects can be added to a heterogeneous array

true, though it's not a good idea

The -- operator is

unary

which of the following is the declaration for a purely virtual function called "myFunction"?

virtual void myFunction() = 0;

class templating

when prefixing the class with something like: template<class T> className<T>::memberName


संबंधित स्टडी सेट्स

English 11 Unit 1 synonyms and antonyms

View Set

microbiology theory final exam chapters 1-15

View Set