Shared Flashcard Set

Details

Nested Classes
n/a
10
Computer Science
Undergraduate 2
01/15/2009

Additional Computer Science Flashcards

 


 

Cards

Term
What is a Nested Class?
Definition
A class declared within another class
Term
Why is Nesting not the same as containment?
Definition
containment is having a class object as a member of another class
Term
What is the reason for using nested classes?
Definition
to assist the implementation of another class and to avoid name conflicts
Term
How would you have a nested constructor initialize a node's item member to i and set the next point to 0 (in the .h)?
Definition
Node(const Item& i) : item(i), next(0) {}
Term
How would you define this nested constructor in Queue in the methods file?

Node(const Item& i) : item(i), next(0) {}

Definition
Queue::Node::Node(const Item& i) : item(i), next(0) {}
Term
What controls the scope of a nested class?
Definition
Where it is declared
Term
What happens when a nested class is declared in a private section of a second class?
Definition
only the second class knows about it
Term
Who knows about a nested class if it is declared in a protected section of a second class?
Definition
the class and any classes derived from it
Term
What if a nested class is declared in the public section of a second class?
Definition
it is available for use to anything
(second class, derived clases, and "outside world")
Term
How do you create a nested object outside of the second class?
Definition
SClass::NClass aname;
Supporting users have an ad free experience!