COSC 052 FINAL final

Ace your homework & exams now with Quizwiz!

True

A class and its members can be described graphically using Unified Modeling Language (UML) notation.

False

A class can have more than one destructor.

When an object is being created and initialized with another object of the same class An object is passed by value as an argument to a function A function returns an instance of a class, by value

A copy constructor is automatically called in the following situations:

A class can have more than one destructor.

False

Exceptions signal errors or unexpected events that occur when code is compiled.A thrown exception could go uncaught if _______________________________________.

False

If a circular linked list is empty, then its tail pointer points to itself.

False

If a stack is implemented as a linked list, it is still consdiered to be a static stack.

False

If a stack is implemented as a linked list, it is still considered to be a static stack.

False

Physical queues are routine in day-to-day life, but queue data structures are uncommon in compute operating systems.

False

The advantage of the linear search is its efficiency, however it is difficult to understand and complex to implement.

False

The enqueue operation returns true if the value specified is stored in the queue.

False

In a circular linked list we maintain a pointer to keep tract of the ________________ Node in the list.

Last

Structures

Lets set of variables be combined in a single unit struct payRoll { int empNumber; string name; double hours, payRate; }; payRoll deptHead, foreman, associate; deptHead.empNumber = 475; foreman.empNumber = 897;

A class and its members can be described graphically using Unified Modeling Language (UML) notation.

True

A derived class can redefine a public member function of the base class.

True

A pointer variable is a variable that stores the address of a memory location.

True

If I implement a stack data structure using a dynamically allocated array to store the elements on the stack, it is still considered a static stack.

True

If a circular linked list contains only one Node, then that Node's next pointer points to itself

True

catch

handles exceptions thrown in a preceding try block. It takes a parameter that matches the type of exception thrown. exception handler.

By default, all members of a class are public.

False

In C++, &p, p, and *p all have the same meaning.

False

Arithmetic expressions written in Polish Notation are using ___________ notation

Prefix

::

Scope resolution operator

The following list of numbers is to be sorted using Selection Sort. 36, 55, 17, 35, 63, 85, 12, 48, 3, 66

The amount of value swaps that are required to completely sort the given list of numbers is -----> 9

Any sort algorithm can be modified to sort in either ascending or descending order.

True

Iterators are objects that behave like pointers.

True

Linear and binary searches can also be used to search for a specific entry in an array of objects or structures. Correct!

True

50 50 20

What will the following program display on the screen? #include <iostream> using namespace std; class Tank { private: int gallons; public: Tank() { gallons = 50; } Tank( int gal ) { gallons = gal; } int getGallons() { return gallons; } }; int main(int argc, const char * argv[]) { Tank storage1, storage2, storage3(20); cout << storage1.getGallons() << endl; cout << storage2.getGallons() << endl; cout << storage3.getGallons() << endl; return 0; }

How are public members of a class ojbect accessed

With the dot operator

The try block is immediately followed by one or more __________ blocks.

catch

Composition = _____ relationship

has-a enclosing class has an instance of the enclosed class

pointer variable

holds addresses of memory locations ex: int *ptr; ptr is a pointer to int. *ptr is variable that ptr points to

Every time the binary search algorithm makes a comparison and fails to find the desired item, it eliminates _______________________ of the remaining portion of the array that must be searched.

one half

a ___ sign in front of a member name on a UML diagram indicates that this member is a public member.

+

A ____ sign in front of a member name on a UML diagram indicates that this member is a private member.

-

A copy constructor is automatically called in the following situations:

- When an object is being created and initialized with another object of the same class - An object is passed by value as an argument to a function - A function returns an instance of a class, by value

A thrown exception could go uncaught if _______________________________________.

- the program contains no catch blocks with an exception parameter of the correct data type. - it is thrown from outside a try block.

a copy constructor is automatically called when:

- when an object is being created and initialized with another object of the same class - an object is passed by value as an argument to a function - a function returns an instance of a class, by value

A C++ implementation file has the extension ____.

.cpp

Class composition

Class composition: A form of aggregation where the enclosing class controls the lifetime of the objects of the enclosed class

The binary search is a ______________ algorithm that is much more ____________ than the linear search.

Clever , Efficient.

False

Constructors are called like any other function.

A stack can be useful in a hand held calculator, but in computer software, stacks are not very useful.

False

All operators can be overloaded as member functions of the class.

False

Constructors are called like any other function. You Answered

False

Exceptions are used to signal errors or unexpected events that occur at compile time.

False

The advantage of linear search is its efficiency, however it is difficult to understand and complex to implement.

False

The process of propagating uncaught exceptions from a function to its caller is called propagating the stack of function calls.

False

There is no way to definitively indicate the end of a linked list.

False

When a node is inserted into a linked list, all of the elements after the insertion point must be moved one position toward the end of the list.

False

When the linear search algorithm is used to search for an item that is not present in an array, it must make a comparison with slightly less than half of the elements in the array.

False

True

Given the declaration int *p; The statement p = new int[50]; dynamically allocates an array of 50 elements of type int and p contains the address of the first element in the array.

True

If p is a pointer variable, the statement p = p + 1; is valid in C++.

memberwise

If the programmer does not specify a copy constructor for a class, then the compiler calls a default copy constructor when necessary; resulting in a ________ assignment.

False

In C++, &p, p, and *p all have the same meaning.

&

In C++, ____ is called the address operator.

copy constructor

In numberArray.h class numberArray { . . . public: numberArray(int size, double value); }; In numberArray.cpp

#ifndef FILENAME_H #define FILENAME_H #endif FILENAME_H Stands for what? Purpose?

Include guard - prevents header file from accidentaly being included more than once "if not defined" - checks for the existence of a constant named "FILENAME_H". if it hasnt been defined yet, its defined, and it includes the rest of the header file.

Arithmetic expressions that we typically write use ________________ notation

Infix.

The _____________ search is a very simple algorithm. Sometimes called the __________ search, it compares each element with the value being searched for, and stops when either the value is found or the end of the array is encountered.

Linear , Sequential

The ___________ search algorithm is adequate for small arrays but not large arrays.

Linear.

The ____________ search algorithm steps sequentially through an array, comparing each item with the search value.

Linear.

Consider the linked list below. circular linked list1 Assume that the basic circular linked list operations have been correctly implemented for this class. Further assume that the identifier for this linked list object is myList. What output will be displayed on screen after this series of operations on the list?

Nothing. These operations are nonsensical.

Bubble sort places _________ of the elements to be sorted in the correct place after each complete iteration of its outer loop.

One

The selection sort places ______________ of the elements to be sorted in the correct place after each complete iteration of its outer loop.

One

Every time the binary search algorithm makes a comparison and fails to find the desired item, it eliminates ___________ of the remaining portion of the array that must be searched.

One half.

Protected members of a base class: how can the outside world and derived members access them?

Outside world: through public members Derived class: directly

True

The preprocessor directive #ifndef is used to prevent multiple inclusions of a header file in a program.

A stack is a data structure that stores and retrieves items in a last-in-first-out (LIFO) manner.

True

A try block must be followed by one or more catch blocks.

True

An exception can propagate backwards along the chain of functions calls until the exception is thrown out of a try block that has a catch block that can handle it.

True

Dynamically allocated data structures may be linked together in memory to form a chain.

True

Given the declaration int *p; The statement p = new int[50]; dynamically allocates an array of 50 elements of type int and p contains the address of the first element in the array. Correct!

True

If i implement a stack data structure using a dynamically allocated array to store the elements on the stack, it is still considered a static stack

True

If p is a pointer variable, the statement p = p + 1; is valid in C++.

True

In C++, an array name is a constant pointer.

True

In many cases, a program will need to test for several different types of errors and signal which one has occured.

True

Sorting and searching algorithms can be applied to arrays, but not to standard template library vectors

True

The preprocessor directive #ifndef is used to prevent multiple inclusions of a header file in a program.

True

Using operator overloading, it is possible to cange an operator's entire meaning.

True

When a throw statement is executed, control is passed to another part of the program known as an exception handler.

True

If I define a class that has a data member that is a pointer, what other members should I also include in the class?

copy constructor, overloaded assignment operator, destructor

Example of a member function

cout << city.length() << endl; //length is a member function

Comparing addresses vs comparing values

if(ptr1 < ptr2) //compares addresses if(*ptr1 < *ptr2) //compares values

*

indirection operator

Arithmetic expressions that we typically write use _____________________ notation.

infix

A derived class can redefine a public member function of the base class.

true

There are ________ possible ways for a thrown exception to go uncaught.

two

Destructor

~Demo(); Demo::~Demo() { }

Example of a class

#include <string> //header file string city, state; //city and states are objects

In C++, ____ is called the address operator.

&

Pointer precendence

*numbers + 1 //adds 1 to contents of 1st array element. arithmetic *(numbers + 1) //adds 1 to address in numbers then deferences. moving to next spot

A ____ sign in front of a member name on a UML diagram indicates that this member is a public member.

+

Consider the program below. What is output when this program executes? #include <iostream> #include <vector> #include <exception> #include <stdexcept> using namespace std; int main() { try { vector<int> a; a.push_back(132); a.push_back(126); a.push_back(49); a.push_back(13); a.push_back(20); int i = 40; if ( i > 4 ) throw "ERROR: index is out of range!"; cout << "a[i] = " << a.at(i) << endl; } catch(out_of_range) { cout << "caught out_of_range exception in function main...\n"; } catch(...) { cout << "unknown exception caught in function main...\n"; } return 0; }

unknown exception caught in function main...

exceptions are

used to signal errors or unexpected events that occur WHILE A PROGRAM IS RUNNING (NOT AT COMPILE TIME)

exception

value or an object that indicates that an error has occurred

function implementation function definitions

void Cicle::setRadius (double r) { radius = r; } double Circle:: getArea() { return 3.14*pow (radius, 2); }

What to put in class declaration prototypes

void setRadius(double); double getArea(); //set has parameters, get does not

Match the text with the correct label on the graph. Big O Graph Correct!

x-axis input size y-axis run size Box A c g(n) Box B f(n) Box C n-zero

Consider the linked list below. double linked list1 Assume that the typiclal linked list operations have been correctly implemented for this class. Further assume that the identifier for this linked list object is myList. After the operations below execute how many dangling pointers will exist? Draw the "state" of the linked list after the following operations have been executed. Identify any dangling pointers and/or memory leaks. (For this question do not try to draw an answer in Canvas. Draw your answer on paper and compare it to the solution attached to Homework 7.) Node *current = tail->previous->previous; delete current->next; tail->previous = NULL;

1

The drawing below represents the "state" of a linked list of Widget objects. All objects on the list are instances of the Widget class. The class has a member function getWeight() that returns the value of the object's weight data member. The class also has a member function getNext() that returns the address stored in the object's next data member. The next data member is a pointer to a Widget object. The number listed within the drawing of each Widget is the value of its weight data member. After the code below executes there will be _________ Widget objects deleted, _________ dangling pointers, and _________ "lost objects" that represent memory leaks.

1, 2, 2. Object with weight 8.0 is deleted, the next pointer of object with weight 7.6 is dangling and the current pointer is dangling; objects with weight 3.2 and 2.6 are "lost" and represent memory leaks.

What is the output of the following code? int *p; int x; x = 12; p = &x; cout << x << ", "; *p = 81; cout << *p << endl;

12,81

Consider the linked list below. circular linked list1 Assume that the basic circular linked list operations have been correctly implemented for this class. Further assume that the identifier for this linked list object is myList. What output will be displayed on screen after this series of operations on the list? int total = 0; while (total < 200) { total += myList.front(); myList.advance(); } cout << total << endl;

227

The following list of numbers is to be sorted using Selection Sort. What is the order of these numbers after one complete iteration of the outer loop using the Selection Sort algorithm. 36, 55, 17, 35, 63, 85, 12, 48, 3, 66

3 55 17 35 63 85 12 48 36 66

The following list of numbers is to be sorted using Bubble Sort. What is the order of these numbers after one complete iteration of the outer loop using the Bubble Sort algorithm. 36, 55, 17, 35, 63, 85, 12, 48, 3, 66

36, 17, 35, 55, 63, 12, 48, 3, 66, 85

Consider the linked list below. double linked list1 Assume that the typiclal linked list operations have been correctly implemented for this class. Further assume that the identifier for this linked list object is myList. After the operations below execute how many dangling pointers will exist? Draw the "state" of the linked list after the following operations have been executed. Identify any dangling pointers and/or memory leaks. (For this question do not try to draw an answer in Canvas. Draw your answer on paper and compare it to the solution posted attached to Homework 7.) head = head->next->next->previous; Node *current = tail; delete current->next; while (current->previous != NULL) { if (current->info < 80) { current = current->previous; delete current->next; } else { current = current->previous; } }

4

What is the output of the following code? int *p; int x; x = 76; p = &x; *p = 43; cout << x << ", " << *p << endl;

43, 43

What is the value of x after the following statements execute? int x = 25; int *p; p = &x; *p = 46;

46

The drawing below represents the "state" of a linked list of Widget objects. All objects on the list are instances of the Widget class. The class has a member function getWeight() that returns the value of the object's weight data member. The class also has a member function getNext() that returns the address stored in the object's next data member. The next data member is a pointer to a Widget object. The number listed within the drawing of each Widget is the value of its weight data member. After the code below executes there will be _________ Widget objects deleted, _________ dangling pointers, and _________ "lost objects" that represent memory leaks.

5, 2, 0. All objects are deleted, there are no memory leaks, but there are two dangling pointers. The widgetList pointer was never moved, so it is still pointing to the address of the first object in the list, but that memory has been deallocated and is no longer valid. The current pointer moved past the end of the list, so it is pointing to NULL and is valid. The pointer byebye stopped on the last object which was also deallocated so byebye is a dangling pointer.

What will the following program display on the screen?

50 50 20

What will the following program display on the screen? #include <iostream> using namespace std; class Tank { private: int gallons; public: Tank() { gallons = 50; } Tank( int gal ) { gallons = gal; } int getGallons() { return gallons; } }; int main(int argc, const char * argv[]) { Tank storage1, storage2, storage3(20); cout << storage1.getGallons() << endl; cout << storage2.getGallons() << endl; cout << storage3.getGallons() << endl; return 0; }

50 50 20

Consider the linked list below. circular linked list1 Assume that the basic circular linked list operations have been correctly implemented for this class. Further assume that the identifier for this linked list object is myList. What output will be displayed on screen after this series of operations on the list? myList.advance(); myList.remove(); myList.remove(); myList.advance(); cout << myList.front() << " " << myList.back() << endl;

76 80

Class aggregation

: An object of one class owns an object of another class

.cpp

A C++ implementation file has the extension ____.

-

A ____ sign in front of a member name on a UML diagram indicates that this member is a private member.

+

A ____ sign in front of a member name on a UML diagram indicates that this member is a public member.

Class composition

A form of aggregation where the enclosing class controls the lifetime of the objects of the enclosed class (has-a relationship between classes)

True

A pointer variable is a variable that stores the address of a memory location.

False

A pointer variable is declared using an ampersand (&) character.

same

A programmer-defined copy constructor must have a single parameter that is a reference to the _________ class.

True

A struct can be passed as a parameter to a function by value or by reference.

False

A struct is a homogeneous data structure with all components of the same type.

false

All operators can be overloaded as member functions of the class.

Class aggregation

An object of one class owns an object of another class

If an array is sorted in ________ order, the values are sorted from lowest to highest.

Ascending

The ____________ search algorithm repeatedly divides the portion of an array being searched in half.

Binary

The ___________ binary search algorithm requires that the array's contents be sorted.

Binary.

Assume a class named Bird exists. Write the header for a member function that overloads the = operator for that class.

Bird Bird::operator=(const Bird &rhsobj);

False

By default, all members of a class are public.

Using a constructor like a struct

Date (int day = 0, int month = 0, int year = 0) { day = 0; month = 00; year = 0000; }

Enumerated data types

Date type created by programmer, contains a set of named constant integers ( Ex: enum Fruit {apple, grape, orange}; )

If an array is sorted in ___________ order, the values are stored from highest to lowest.

Descending

____ is the ability to combine data, and operations on that data, in a single unit.

Encapsulation

A derived class can directly access any member of the base class.

False

A derived class cannot directly access public members of a base class.

False

A linked list consists of a series of self-referential objects. Each object has a pointer to the next object in the list. This is the only possible design of a linked list.

False

A pointer variable is declared using an ampersand (&) character.

False

A queue is a data structure that stores and retrieves items in a last-in-first-out (LIFO) manner

False

A queue is a data structure that stores and retrieves items in a last-in-first-out (LIFO) manner.

False

Difference between overrriding and overloading

Overriding = the redef of a member function by a derived class when the base class already has a member function with the same name and parameter list Overloading = the redef of functions within the same class with the same name and different parameter lists

From the list below, select the three characteristics of Object Oriented Design (OOD) / Object Oriented Programming (OOP).

Polymorphism, Inheritance, Encapsulation

What are the three characteristics of Object Oriented Design (OOD) / Object Oriented Programming (OOP).

Polymorphism, inheritance, encapsulation

Arithmetic expressions written in Reverse Polish Notation are using _________ notation.

Postfix

Constructor with one parameter example

Sale(double rate) {taxRate = rate; }

Abstract Data Type

Specifies the value the data type can hold the operations that can be done on them without the details of how the data type is implemented

A stack is a data structure that stores and retrieves items in a last-in-first-out (LIFO) manner

True.

Linear and binary searches can also be used to search for a specific entry in an array of objects or structures.

True.

UML stands for

Unified Modeling Language

Member initialization lists

Used in constructors for classes involved in aggregation, Allows constructor for enclosing class to pass arguments to the constructor of the enclosed class

true

Using operator overloading, it is possible to change an operator's entire meaning.

True

Usually class declarations are stored in their own header files (specification files) and member function definitions are stored in their own .cpp files (implementation files).

Inheritance order of execution

When an object is created in the derived class, the base class constructor is executed first, then the derived class constructor is executed. When an abject is destroyed in the derived class, the derived class destructor is executed first, followed by the base class destructor

Encapsulation

____ is the ability to combine data, and operations on that data, in a single unit.

Dangling Pointer

a pointer contains the address of memory that has been freed by a call to delete (solution is to set ptr to NULL after deletion)

Assume that an iterator class having identifier LL_iterator exists. The iterator class implements an overloaded dereferencing operator: LL_iterator::operator*(). The return value for this operator is ________________________.

a reference to the info data member of the node to which the iterator points

Inheritance

a way of creating a new class by starting with an existing class and adding new members (is-a relationship between classes)

Consider the program below. What is output when this program executes? #include <iostream> #include <vector> #include <exception> #include <stdexcept> using namespace std; int main() { try { vector<int> a; a.push_back(132); a.push_back(126); a.push_back(49); a.push_back(13); a.push_back(20); cout << "a[3] = " << a.at(3) << endl; } catch(out_of_range) { cout << "caught out_of_range exception in function main...\n"; } catch(...) { cout << "unknown exception caught in function main...\n"; } return 0; }

a[3] = 13

Consider the program below. What is output when this program executes? #include <iostream> #include <vector> #include <exception> #include <stdexcept> using namespace std; int main() { try { vector<int> a; a.push_back(132); a.push_back(126); a.push_back(49); a.push_back(13); a.push_back(20); int i = 4; if ( i > 4 ) throw "ERROR: index is out of range!"; cout << "a[i] = " << a.at(i) << endl; } catch(out_of_range) { cout << "caught out_of_range exception in function main...\n"; } catch(...) { cout << "unknown exception caught in function main...\n"; } return 0; }

a[i] = 20

The basic linked list operations are:

adding an element to a list removing an element from the list traversing the list destroying the list

The basic linked list operations are:

adding an element to the list, removing an element from the list, traversing the list, destroying the list

Pointer

address of a memory location

Use dynamic memory allocation for arrays w/ pointers (ptr = arrayPtr and double at 25)

arrayPtr = new double[25];

Existing classes, from which you create new classes, are called ____ classes.

base

A linked list class that uses iterators provides the following member functions specifically for that purpose.

begin() end()

The _____________________ search algorithm repeatedly divides the portion of an array being searched in half.

binary

The ________________________ search algorithm requires that the array's contents be sorted.

binary

Constructor

called when class object is created. name is the same as name of class, no return type, no parameters if default Class Demo { public: Demo() //contructor Demo::Demo() }

Consider the program below. What is output when this program executes? #include <iostream> #include <vector> #include <exception> #include <stdexcept> using namespace std; int main() { try { vector<int> a; a.push_back(132); a.push_back(126); a.push_back(49); a.push_back(13); a.push_back(20); cout << "a[3] = " << a.at(30) << endl; } catch(out_of_range) { cout << "caught out_of_range exception in function main...\n"; } catch(...) { cout << "unknown exception caught in function main...\n"; } return 0; } Correct!

caught out_of_range exception in function main...

The binary search is a(n) ____________________ algorithm that is much more ____________________ than the linear search.

clever/efficient

when a throw statement is executed..

control is passed to another part of the program known as an exception handler

Correct function implementation

double getArea() //wrong Circle::double getArea() // wrong double Circle::getArea() //right

The basic operations of a circular linked list are:

empty, add, front, back, remove, advance

______is the ability to combine data, and operations on that data, in a single unit.

encapsulation

a piece of code is said to be polymorphic if

executing the code with different types of data produces different behavior

(T/F) all operators can be overloaded as member functions of the class

false

(T/F) by default all members of a class are public

false

(T/F) constructors are called like any other function

false

A derived class can directly access any member of the base class.

false

A derived class cannot directly access public members of a base class.

false

When a node is inserted into a linked list, all of the elements after the insertion point must be moved one position toward the end of the list.

false

try

followed by a block { }, is used to invoke code that throws an exception (equiv to an if statement)

throw

followed by an argument, is used to signal an exception (this must be within try block)

program to enter numbers and display

int main( ) { const int SIZE = 5; int numbers[size]; cout << "Enter " << size << " numbers: "; for (int count = 0; count < SIZE; count ++) cin >> *(numbers + count); cout << "Here are teh numbers you entered:\n"; for(int count = 0; count < SIZE; count++) cout << *(numbers + count) << " "; cout << endl; return 0; }

example of a pointer variable

int main() { int x = 25; int *ptr; ptr = &x; cout << x << endl; cout << ptf << endl; } output: 25 [address of x]

Array name as pointer

int main() { short numbers[ ] = {10, 20, 30}; cout << *numbers << endl; return 0; } output: 10 //first number of array

Initializing pointers

int myvalue; int *pint = myValue; or int ages[20]; int *pint = ages

Pointer property

int x = 25 int *ptr; ptr = &x cout << ptr << " " << x; output: [address of x] 25

Inheritance = ____ relationship

is-a

Inheritance is an example of a(n) ____ relationship.

is-a

After one pass of the bubble sort, the ___________ value is in its proper order; after one pass of the selection sort, the __________ value is in its proper order.

last --> first.

throw point

line containing throw statement

The ___________________ search algorithm steps sequentially through an array, comparing each item with the search value.

linear

The _____________________ search algorithm is adequate for small arrays but not large arrays.

linear

The _____________________ search is a very simple algorithm. Sometimes called the ________________________ search, it compares each element with the value being searched for, and stops when either the value is found or the end of the array is encountered.

linear/sequential

A data structure that points to an object of the same type as itself is known as a(n) ____________________ data structure.

linked

If the programmer does not specify a copy constructor for a class, then the compiler calls a default copy constructor when necessary; resulting in a ________ assignment.

memberwise

If I write code that dynamically allocates memory with the operator new, I must remember to deallocate that memory using the operator delete. Failing to do so results in a(n) ___________________ .

memory leak

Consider the linked list below. double linked list1 This linked list is an instance of the doubly linked list class having the class name DLL. This is a non-template class. Nodes on the linked list have an info data member of type int. Write a member function for class DLL that will output the contents of each Node's info data in reverse order. Use iteration (not recursion). (For this question do not try to write the code in Canvas, write your code by hand or type into an IDE, then compare your answer to the solution attached to Homework 7.) How many lines of code does your function require?

more than 1

Objects sent to default constructor

no parenthesis ex: Sale cashier; // not Sale cashier();

Memory leak

occurs if no-longer-needed dynamic memory is not freed

Assume that a linked list class having identifier LL exists. The class provides a method end() returns an iterator object. The iterator object returned by end() points to what position within the linked list?

one position past the last node on the linked list

Assume a class named Length exists. Write the header for a friend function that overloads the stream insertion << operator for that class.

ostream& operator<<(ostream &os, const Length &rhsobj);

Arithmetic expressions written in Reverse Polish Notation are using _____________ notation.

postfix

Assume that an iterator class having identifier LL_iterator exists. The iterator class implements the following overloaded operator: LL_iterator::operator++(). This is the _________________________ operator.

pre-increment

Arithmetic expressions written in Polish Notation are using _____________ notation.

prefix

the preprocessor directive #ifndef is used to

prevent multiple inclusions of a header file in a program

Class

programmer identified data type that describes what objects of the class will look like when they're created

Access Specifiers

public and private member variables usually private, member functions usually public

Consider the following function stub: LL_iterator LL::end() { } Select the best option from the given choices for this method's implementation code.

return LL_iterator(NULL);

Consider the following function stub: LL_iterator LL::begin() { } Select the best option from the given choices for this method's implementation code.

return LL_iterator(head);

Copy of Consider the following function stub: int& LL_iterator::operator*() const { } Select the best option from the given choices for this method's implementation code.

return current->info;

Default Constructor Example

sale() { taxRate = 0.0 }

A programmer-defined copy constructor must have a single parameter that is a reference to the _________ class.

same

A data structure that points to an object of the same type as itself is known as a(n) ____________________ data structure.

self-referential

Name array and use as pointer

short numbers[ ] = {10, 20} cout << *number << endl; output: 10

exception handler

special code for handling the exception. catch block.

Initializing a structure

struct Date {int day, month, year; }; Date birthday = {23, 8, 1983};

Assume that a linked list class having identifier LL exists. The class provides a method begin() returns an iterator object. The iterator object returned by begin() points to what position within the linked list?

the first node on the linked list

Two linked list iterator objects are equal if _____________________________________________________.

they both store the same memory address in their current data member

The process of beginning at the head of a list and going through the entire list while doing some processing at each node is called ______________ the list.

traversing

(T/f) If p is a pointer variable, the statement p = p + 1; is valid in C++.

true


Related study sets

Week 11 Assignment - Structural Abnormalities of the Face, & Head

View Set