Question

12. Consider C++ class. Which one of the following choices is NOT correct? A. Class instances...

12. Consider C++ class. Which one of the following choices is NOT correct?

A. Class instances can be static, stack dynamic, or heap dynamic.

B. If static or stack dynamic, they are referenced directly with value variables.

C. If stack dynamic, they are referenced through pointers.

D. Stack dynamic instances of classes are always created by the elaboration of an object declaration.

E. The lifetime of such a class instance ends when the end of the scope of its declaration is reached.

13. Consider C++ class. Which one of the following choices is NOT correct?

A. Heap dynamic class instances are created with the new operator.

B. Heap dynamic class instances are destroyed with the delete operator.

C. Stack-dynamic classes can have pointer data members that reference heap dynamic data.

D. Heap-dynamic classes can have pointer data members that reference stack-dynamic data.

14. Consider C++ class. Which one of the following choices is NOT correct?

A. C++ allows the user to include constructor, to initialize the data members of newly created objects.

B. C++ constructor may also allocate the heap-dynamic data that are referenced by the pointer members of the new object.

C. C++ Constructors are implicitly called when an object of the class type is created.

D. C++ constructor has the same name as the class whose objects it initializes.

E. C++ Constructors can be inherited but cannot be overloaded.

15. Consider C++ class. Which one of the following choices is NOT correct?

A. C++ class can also include a destructor, which is implicitly called when the lifetime of an instance of the class ends.

B. Destructor function can include a delete operator on the pointer members to deallocate the heap space they reference.

C. Destructors are often used as a debugging aid, in which case they simply display or print the values of some or all of the object’s data members before those members are deallocated.

D. The name of a destructor is the class’s name, preceded by a tilde (~).

E. Constructors or destructors have return types.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

13.
   Ans: D. Heap-dynamic classes can have pointer data members that reference stack-dynamic data.
14.
   Ans: E. C++ Constructors can be inherited but cannot be overloaded.

15.
   ANs: E. Constructors or destructors have return types.

Add a comment
Know the answer?
Add Answer to:
12. Consider C++ class. Which one of the following choices is NOT correct? A. Class instances...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please write the code in C++ 2 Base class File 3 Derived class PDF 3.1 Class...

    please write the code in C++ 2 Base class File 3 Derived class PDF 3.1 Class declaration • The class PDF inherits from File and is a non-abstract class 1. Hence objects of the class PDF can be instantiated. 2. To do so, we must override the pure virtual function clone) in the base class • The class declaration is given below. • The complete class declaration is given below, copy and paste it into your file. . It is...

  • Hi all, I need help to do a project based on C++ smart pointers. I have...

    Hi all, I need help to do a project based on C++ smart pointers. I have to implement the class template my_unique_ptr which is a pointer management class template. Also, it's required to implement the following public methods: a. Default constructor that initializes the object to point to nullptr. b. Constructor that takes a pointer Type * as a parameter and sets the object to point there. We say that the newly created object takes ownership of the pointed memory....

  • About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which...

    About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which has private data members for name, age, gender, and height. You MUST use this pointer when any of the member functions are using the member variables. Implement a constructor that initializes the strings with an empty string, characters with a null character and the numbers with zero. Create getters and setters for each member variable. Ensure that you identify correctly which member functions should...

  • please write in c++. 4 Derived class JPG 4.1 Class declaration • The class JPG inherits...

    please write in c++. 4 Derived class JPG 4.1 Class declaration • The class JPG inherits from File and is a non-abstract class. 1. Hence objects of the class JPG can be instantiated. 2. To do so, we must override the pure virtual function clone() in the base class. • The class declaration is given below. class JPG : public File { public: JPG(const std::string& n, int n, int w, const double rgb()) : File(...) { // ... } *JPG()...

  • c++ Part 1 Consider using the following Card class as a base class to implement a...

    c++ Part 1 Consider using the following Card class as a base class to implement a hierarchy of related classes: class Card { public: Card(); Card (string n) ; virtual bool is_expired() const; virtual void print () const; private: string name; Card:: Card() name = ""; Card: :Card (string n) { name = n; Card::is_expired() return false; } Write definitions for each of the following derived classes. Derived Class Data IDcard ID number CallingCard Card number, PIN Driverlicense Expiration date...

  • 1. Here are codes to define a stack class based on dynamic array, please complete the...

    1. Here are codes to define a stack class based on dynamic array, please complete the copy constructor //--- Definition of Stack copy constructor Stack::Stack(const Stack & original) : myCapacity(original.myCapacity), myTop(original.myTop) { //--- Get new array for copy myArray = new(nothrow) StackElement[myCapacity]; if (myArray != 0) // check if memory available                         // copy original's array member into this new array {              // Please complete the function here        } else {          cerr << "*Inadequate memory to allocate...

  • Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p;...

    Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p; int i; int k; i = 42; k = i; p = &i; After these statements, which of the following statements will change the value of i to 75? A. k = 75; B. *k = 75; C. p = 75; D. *p = 75; E. Two or more of the answers will change i to 75. Consider the following statements: int i =...

  • number 4 in c++ please square method not mentioned no sauare method was given. can thus...

    number 4 in c++ please square method not mentioned no sauare method was given. can thus be solved without a specific square mthod? Laboratory work 12 Investigation of using classes for describing class data-members Task 1. Study class members definition in C++ and CH. 2. Study class and members access modifiers in C++ and Ce 3. Study mechanisms creation, 4. Write programs in C++ and C which demonstrate use cases of class according to variant of creation, usage, and destruction...

  • 2 Class Vec Message1 2.1 Introduction • Write a class Vec Message1 with the following declaration....

    2 Class Vec Message1 2.1 Introduction • Write a class Vec Message1 with the following declaration. class Vec_Message1 { public: Vec_Message1(); Vec_Message1(int n); Vec_Message1(int n, const Message1 &a); Vec_Message1(const Vec_Message1 &orig); Vec_Message1& operator= (const Vec_Message1 &rhs); ~Vec_Message1(); int capacity() const; int size() const; Message1 front() const; Message1 back() const; void clear(); void pop_back(); void push_back(const Message1 &a); Message1& at(int n); private: void allocate(); void release(); int _capacity; int _size; Message1 * _vec; }; 2.2 allocate() and release() • Examine the...

  • Overload a relational operator for the Job class: Assume that this operator is not overloaded for...

    Overload a relational operator for the Job class: Assume that this operator is not overloaded for the Salary class. a) Write how the function will be declared in your code. b) Write an external function definition (not inside the class). solve it in C++10 to solve this you nedd question number 1. Create a composition between the classes Job and Salary. Class Salary a. data member:    1. money b. constructors:    1. default constructor    2. user defined constructor with a parameter...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT