Ch 10 C++

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

What is the UML notation for a protected member?

#:

What is the UML notation for a public member?

+:

What are the built in operations that are valid for class objects?

- member access (.) - assignment (=)

What is the UML notation for a private member?

-:

What is the problem with passing by reference when passing a variable to a parameter? What is the solution?

1. when passing by reference, the actual parameter changes when the formal parameter changes 2. solution is use const in the formal parameter declaration

If a class provides a constructor with parameters, but no default constructor, what does C++ do?

C++ does not provide the default constructor

What happens is a class has no constructors?

C++ provides a default constructor (however, object declared is still uninitialized)

The number and type of parameters must match the formal parameters (in the correct order) of one of the constructors, otherwise...

C++ uses a type conversion and looks for the best match (any ambiguity causes a compile-time error)

What is a class variable called?

a class object or class instance

What is a class?

a collection of a fixed number of components

What is a member?

a component of a class

What is a default constructor?

a constructor with no parameters or with all default parameters

What is an abstract data type (ADT)?

a data type that separates the logical properties from the implementation details

If you declare an array of class objects, what should be included?

a default constructor

What is a mutator function?

a member function that modifies the value(s) of member variable(s)

What is an accessor function?

a member function that only accesses the value(s) of member variable(s)

What is object-oriented-design?

a problem solving methodology

What is a precondition?

a statement specifying the conditions that must be true before the function is called

What is a postcondition?

a statement specifying what is true after the function call is completed

System-provided header files are inclosed in what?

angular brackets <>

How is a class member accessed outside the class?

by using the class object name and member access operator (.)

Classes and structs have the same ________.

capabilities

What is the syntax for a class?

class classIdentifier {classMemberList};

A public static function or member of a class can be accessed using what?

class name and the scope resolution operator

What is the syntax for invoking a constructor with parameters?

className classObjectName (argument1, argument2, ...);

What is the syntax to invoke the default constructor?

className classObjectName;

What is the syntax for an object accessing the public member of a class?

classObjectName.memberName (the dot is the member access operator)

A program that uses/manipulates objects of a class is called a ________ of that class.

client

What are objects?

components of a solution

If an object is passed by value, what happens to contents of data members?

contents of data members of the actual parameter are copied into the corresponding data members of the formal parameter

What does it mean for an object to be static?

created when the declaration is reached and destroyed when the program terminates

What does it mean for an object to be automatic?

created when the declaration is reached and destroyed when the surrounding block is exited

Abstraction can be applied to what?

data

Rules for declaring formal parameters in a constructor are the same as what?

declaring default formal parameters in a function (actual parameters are passed according to the same rules as for functions)

What does a class do?

defines a data type; no memory is allocated

In the include statement, user defined header files are inclosed in what?

double quotes

What should be included in the header file?

function prototypes and comments that briefly describe the functions (specify pre or post conditions)

What are destructors?

functions without any type that automatically executes when the class goes out of scope

What is information hiding?

hiding the details of the operations on the data

What does the implementation file contain (.cpp file)?

implementation details

If a member of a class is a function, what is done with the function prototype?

it is listed

What is the downside to passing by value?

it might take a considerable amount of storage space, and require a bit of time to copy the value of the actual parameter into the formal parameter

When you declare objects of the class clockType, each object has what?

it's own copy of the member variables (hr, min, & sec)

If a member of a class is a variable, how is it declared?

just like any other variable

What keyword do you use to declare a function or variable of a class as static?

keyword static

What is the definition of a private class member?

member cannot be accessed outside the class

What is a constant function?

member function that cannot modify member variables (use const in the function heading)

What is the definition of a public class member?

member is accessible outside the class

Can constructors be called like other functions?

no

Can relational operators be used to compare two class objects for equality?

no

Do most of C++'s built in operations apply to classes?

no

Does C++ have a fixed order in which to display public and private members?

no

Does a constructor have a type?

no

Does the destructor have parameters?

no

If a member of a class is a variable, be initialized after it is declared?

no

Can arithmetic operators be used on class objects?

not unless the operators are overloaded

When can an object access the public members of a class?

once it is declared

When can a class be used in a program?

once it is properly defined and implemented

When can you declare variables of a certain class type?

once that class type is defined

How many destructors can a class have?

one

What are the two types of constructors?

one with parameters, and one without parameters (default constructor)

If a variable is passed by reference, the formal parameter receives what?

only the address of the actual parameter

An object has the same scope as what?

other variables

Objects can be passed as ________ to functions and returned as __________ values.

parameters; function

By default, all members of a class are public or private?

private

What are the three categories of class members?

private, public, and protected

By default, members of a struct are public or private?

public

What is abstraction?

separating design details from usage; separating the logical properties from the implementation details

What does the interface (header) file (.h file) contain?

specification details

An object can be automatic or ________.

static

What makes up the name of a constructor?

the character '~' followed by class name

A member of a class is local to what?

the class

To use an object in a program, the program must be able to access what?

the implementation

Why are prototypes left in the class?

the keep the class smaller and hide implementation

What is the name of a constructor?

the name of the corresponding class

What determines which constructor executes?

the types of values passed to the class object when the class object is declared

How do you make a member available for public access?

use the member access specifier public

What is Unified Modeling Language (UML) notation?

used to graphically describe a class and its members

How can a member of a struct be made private?

using a private specifier

How do you guarantee that member variables of a class are initialized?

using constructors

How do you access identifiers local to a class?

using the scope resolution operator ::

As parameters to functions, objects can be passed by ___________ or by ___________.

value; reference

What is an instance variable?

variables that each object of a class has

The implementation file must include the header file.. how?

via the include statement

When do constructors execute?

when a class object enters its scope, the constructors execute automatically

When is a constructor automatically executed?

when a class variable is declared

When is it best to use a struct vs a class?

when all member variables of a class are public and there are no member functions

When can an object access public and private members of a class?

when the object is declared in the definition of a member function of a class

Can a class member be a variable of a function?

yes

Can a constructor have default parameters?

yes

Do all objects of a class share any static member of the class?

yes

Do multiple objects of a class have their own copy of non-static member variables?

yes

Do static member variables exist even if no object of that class type exists?

yes

If a member of a class is a function, can function members directly access any member of the class?

yes

Can a class have more than one constructor?

yes, but each must have a different formal parameter list


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

National Flood Insurance Program (NFIP)

View Set

PCI Data Security Standard Study Materials

View Set

AP CHEM BIG IDEA #2 MULTIPLE CHOICE

View Set

Fundamentals of Management by Griffin Chapter 14

View Set

Chapter 1: Consumer Safety and Drug Regulations

View Set