In object-oriented programming, the object encapsulates both the data and the functions that operate on the data.
True
False
Flag this Question
Question 101 pts
You must declare all data members of a class before you declare member functions.
True
False
Flag this Question
Question 111 pts
You must use the private access specification for all data members of a class.
True
False
Flag this Question
Question 121 pts
A private member function is useful for tasks that are internal to the class but it is not directly called by statements outside the class.
True
False
Flag this Question
Question 131 pts
If you do not declare a destructor function, the compiler will furnish one automatically.
True
False
Flag this Question
Question 141 pts
When an object is defined without an argument list for its constructor, the compiler automatically calls the object's default constructor.
True
False
Flag this Question
Question 151 pts
Constructor functions are often used to allocate memory that will be needed by the object.
True
False
Flag this Question
Question 161 pts
Destructor functions are often used to free memory that was allocated by the object.
True
False
Flag this Question
Question 171 pts
While a class's member functions may be overloaded, the constructor cannot be overloaded.
True
False
Flag this Question
Question 181 pts
When using smart pointers to dynamically allocate objects in C++ 11, it is unnecessary to delete the dynamically allocated objects because the smart pointer will automatically delete them.
True
False
9. True 10. False 11. False 12. True 13. True 14. True 15. True 16. True 17. True 18. True
In object-oriented programming, the object encapsulates both the data and the functions that operate on the...
In a function template, a generic data type starts with the key word _____ followed by a parameter name that stands for the data type. template class T function Which of the following blocks is designed to catch any type of exception? catch(){ } catch(...){ } catch(*){ } catch(exception){ } A friend function can only be a regular stand-alone function and can not be a member of another class. True False A function template is an actual function that the...
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...
In C++ Write a program that contains a class called VideoGame. The class should contain the member variables: Name price rating Specifications: Dynamically allocate all member variables. Write get/set methods for all member variables. Write a constructor that takes three parameters and initializes the member variables. Write a destructor. Add code to the destructor. In addition to any other code you may put in the destructor you should also add a cout statement that will print the message “Destructor Called”....
1. Create an “include guard” (all lines of code required) for a file “plane.h” 2. When you look at a constructor, how can you determine if it is THE default constructor? 3. What can a “friend” function do that other non-member functions can not do? 4. class plane { int x;} ---------------- is x public or private? 5. What kind of a search first sorts the data into ascending or descending order, then splits the data in half, searches, splits,...
Provide short answers for the following C++ questions const - data members: - how can you initialize data members that are const: - member functions: - how to declare member functions that operate on a const object: - why declare them to handle const objects: inheritance: - class hierarchy - order of events when a derived-class object is instantiated and destroyed -constructor initialization list
Part 1. (60 pts) 1. Define an Address class in the file Address.h and implement the Address class in Address.cpp. a. This class should have two private data members, m_city and m_state, that are strings for storing the city name and state abbreviation for some Address b. Define and implement public getter and setter member functions for each of the two data members above. Important: since these member functions deal with objects in this case strings), ensure that your setters...
C++ Question 1) Consider a class Point that models a 2-D point with x and y coordinates. Define the class point that should have the following Private data members x and y (of type int), with default values of 0 A constant ID of type int A private static integer data member named numOfPoints This data member should be o Incremented whenever a new point object is created. o Decremented whenever a point object is destructed. A default constructor An...
6. Declare an object Plane with nothing but a private constructor and destructor. You do not need to define either the constructor or destructor. 7. Create a vector that can hold Plane objects but do not set an initial size or initialize any elements 8. What kind of variable type is used to store a memory address 9. What operator is used to dereference a pointer to a structure? 10. If you intent on doing file I/O, what #include do...
C++ //add as many comments as possible 5. A complex number consists of two components: the real component and the imaginary component. An example of a complex number is 2+3i, where 2 is the real component and 3 is the imaginary component of the data. Define a class MyComplexClass. It has two data values of float type: real and imaginary This class has the following member functions A default constructor that assigns 0.0 to both its real and imaginary data...