Exam 6: Structures and Classes

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Multiple public: and private: sections are prohibited in a class.

Free
(True/False)
4.8/5
(36)
Correct Answer:
Verified

False

C++ allows the programmer to deal with data at a higher level of abstraction in part because related data of differing types can be treated as a unit in

Free
(Multiple Choice)
4.8/5
(40)
Correct Answer:
Verified

B,E

What is the reason for separating the interface from the implementation of an ADT?

Free
(Essay)
4.8/5
(36)
Correct Answer:
Verified

One obvious benefit is that you can change your client (program that uses the ADT)without requiring that the ADT details be changed.The other benefit is that the ADT author can change the ADT implementation (but not the interface)of the ADT without requiring the client to do anything but relink his code.

The dot operator is used between an object and a data member or between a calling object and a call to a member function from the class of the object.

(True/False)
4.9/5
(41)

Carefully distinguish between the scope resolution operator,and the dot operator.

(Essay)
4.9/5
(39)

A class is a type similar to a structure type that normally has member functions as well as member variables.

(True/False)
4.8/5
(39)

Given the ShoeType structure type-definition.Write a function for the declaration (prototype). struct ShoeType { char style; double price; }; void setSalePrice(ShoeType& Item,double discountRate); //discountRate =(discounted price)/(regular price) //Adjusts sale price to reflect the specified discount.

(Essay)
4.8/5
(41)

A sure test of whether you have succeeded in producing an Abstract Data Type (whether you have truly separated the interface from the implementation)is whether you can use the ADT then change either the implementation or the client code without being required to change the other.

(True/False)
4.8/5
(43)

Here are several different initializations of a structure variable.State what happens in each initialization. struct WeatherData { int temperature; int windChill; int windSpeed; }; a)WeatherData prediction ={ }; b)WeatherData prediction ={40}; c)WeatherData prediction ={40,-10,}; d)x WeatherData prediction ={40,-10,20 };

(Essay)
4.8/5
(31)

In defining a member function whose declaration is in a class,you use the dot operator to specify that the member function being defined belongs in the class,as class foo { public: // other members void output( ); // other members }; void foo.output( ) { /* whatever */ }

(True/False)
4.9/5
(32)

A structure member is access using the index operator [ ],with the member name as index.[ ]

(True/False)
4.8/5
(42)

A C++ structure,or struct,like the C++ array,is a homogeneous data structure.(i.e. ,all data is of the same type)

(True/False)
4.7/5
(45)

Carefully define mutator and accessor functions of a class.

(Essay)
4.9/5
(38)

What is the error in the following structure definition? struct A { int b; int c; } int main() { A x; // other code }

(Essay)
4.9/5
(38)

Consider the class and struct definitions below. struct myStruct { \quad int i; \quad double d; }; class myClass { \quad int i; \quad double d; }; myStruct a; a.i = 3; myClass b; b.i = 3; True or False: All these statements will compile with no problem.

(True/False)
4.8/5
(36)

There is no aggregate initialization available for structure variables.You must declare structure variables then use assignment to initialize the members.

(True/False)
4.9/5
(39)

A structure can have a member whose type is another structure.

(True/False)
5.0/5
(31)

A class type cannot be used in some ways that a built-in type can be used.

(True/False)
4.7/5
(34)

A member of a structure or of a class is accessed using the

(Multiple Choice)
4.7/5
(44)

A structure variable can be defined directly in the same statement that defines a structure definition.

(True/False)
4.9/5
(37)
Showing 1 - 20 of 37
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)