Default constructor

Question: A member function should be declared static if it does not access __________

class members

Non-static

Question: Member objects are constructed __________ their enclosing class object

Before

Question: The __________ operator reclaims memory previously allocated by new.

Delete

Question: Find the errors in the following class and explain how to correct them:

class Example

{

public: Example(int y = 10)

: data(y)

{

// empty body

} // end Example constructor

int getIncrementedData() const

{

return data++;

} // end function getIncrementedData

static int getCount()

{

cout << "Data is " << data << endl;

return count;

} // end function getCount

private:

int data;

static int count;

}; // end class Example

Error: The class definition for Example has two errors. The first occurs in function

GetIncrementedData. The function is declared const, but it modifies the object.

Correction: To correct the first error, remove the const keyword from the definition of

GetIncrementedData.

Error: The second error occurs in function getCount. This function is declared static, so it

Is not allowed to access any non-static member of the class.

Correction: To correct the second error, remove the output line from the getCount

Definition.

Question: Input/output in C++ occurs as ____________ of bytes

Streams

Question: The stream manipulators that format justification are_________, _________

and _______.

Left, right and internal

Question: Member function _________ can be used to set and reset format state

Flags

Question: Most C++ programs that do I/O should include the _________ header file that

contains the declarations required for all stream-I/O operations.

<iostream>

Question: When using parameterized manipulators, the header file ____________ must

be included

<iomanip>

Question: Header file __________ contains the declarations required for user-controlled

file processing

<fstream>

Question: The ostream member function ___________ is used to perform unformatted

output

Write

Question: Input operations are supported by class __________.

Istream

Question: Outputs to the standard error stream are directed to either the ___________ or

the ___________ stream object

Cerr or clog

Question: Output operations are supported by class ___________.

Ostream

Question: The symbol for the stream insertion operator is ____________.

<<

Question: The four objects that correspond to the standard devices on the system include

_________, _________, __________ and ___________.

Cin, cout, cerr and clog

Question: The symbol for the stream extraction operator is __________

>>

Question: The stream manipulators ___________, __________ and ___________

specify that integers should be displayed in octal, hexadecimal and decimal formats,

respectively


Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: