C++ (p1)

ducopubi's version from 2016-04-02 20:45


Question Answer
What is a class Variable?variable in a class declared to be static
Describe a behavior member function an instance or class (static) method (member function)
What is a statevalue of all fields at an instant in time
What is a constructor?a special member function of a class that is executed whenever we create new objects of that class.
What are some characteristics of a constructorWill have the same name as class; Does not have return type, not even void; Can be used to set initial values
What is a destructor?a special member function of a class that is executed whenever an object of it's class goes out of scope or whenever the delete expression is applied to a pointer to the object of that class.
What are some characteristics of a destructor?Will have the same name as class with prefixed with a ( ~ ); Can't have return type nor take parameters
What is a set function?public function that sets values of a protected data member; Does not return any value
What is a get function?public function that returns the value of protected data member; Does not need arguments
Identify a function to display the "state" of an objectthe print() function
Define encapsulationan Object Oriented Programming concept that binds together the data and functions that manipulate the data, and that keeps both safe from outside interference and misuse
Two different type of class declarations?struct or class
When should you use struct?use when you are only declaring public fields
When should you use class?use if you are declaring a new abstract data type (ADT)
What is an inline member function?function defined fully inside a class declaration
List 3 access specifierspublic, private, protected
what is the default access for a classprivate
what is the default access for a structurepublic
Are protected data members directly accessible in a derived class member function?TRUE
(T/F) static member functions can be called without an objectTRUE
(T/F) non-static member functions can be called without an objectFALSE
How can static fields & functions be accessed?If no object exists then must be accessed with class name & resolution operator ( Circle::getNumCircles() )
How to access static fields and functions if object existscan be accessed using object handle (myCircle.getNumCircles(); )
What is const keyword?used in a function prototype or function header; these functions can't make changed to any fields in a class;
what is the function of the delete keyworduse in a base class to "delete" the constructor from a derived class
final keyword?cannot be a base class (because no class can be derived from it)
override?used in derived class declaration to signal inherited virtual function to be overridden
what is the static keyword use forusually used to declare a "class" field or method; this use can only be used in class declarations
using?used in a derived class to inherit a base class constructor
virtual?use to declare a virtual function; can only be used in class declaration
What does the keyword const at the end of a member function protoype indicate?used to indicate that a method will not change any fields in an object of the class
Override at the end of function protoypeforces compiler to check whether the base class has a member function with the same name and parameter; if not then compiler generates error;
Why is the override keyword used at the end of function prototypeto insure inherited virtual function is overridden rather than overloaded
when can the override keyword be usedcan only be used in function header in a class declaration
Does a class constructor have a return type?No return type
Can a class constructor return a valuedoes not return value
(T/F) default constructor created by C++ initializes fieldsFALSE
What are some characteristics of a user created default constructor?Empty Parameter list; provides default values for all parameters
(T/F) constructors can be overloaded?TRUE
Example of constructor member intializersFoo( int a, int b )x(a), y(b) { <body> }
when should you use the explicit keyword?when declaring a constructor with one parameter to prevent the constructor from being used implicitly as a conversion function
When can you omit the ( ) When creating an object using a default constructor (Ex: Circle c; )