Purchase Solution

C++ Programming: Constructors and Destructors

Not what you're looking for?

Ask Custom Question

Please help identify the following statements as either true or false. If an answer is true, I need to explain why and, where appropriate, provide an example. If the answer is false, I also need to explain why.
a. Constructors can have names different from their classes.
b. Destructors have default arguments.
c. If a program uses the delete operator, a destructor is not needed.
d. Explicit constructors need to be included in every class.
e. Destructors are called each time an object goes out of existence.
f. A class can have several default constructor functions.
g. Constructors need to be declared for each class.
h. Constructors are automatically called when objects are created.

Purchase this Solution

Solution Summary

The solution discusses c++ programming including constructors and destructors.

Solution Preview

a. Constructors can have names different from their classes - FALSE.
Constructor must always have the same name as their class, otherwise the compiler will not know that it is a constructor. The declaration syntax is different from other members - there is no return type defined.
Eg.

class MyClass
{
public:

MyClass();
};

b. Destructors have default arguments. - FALSE
Destructors have no arguments.
Eg.

class ...

Purchase this Solution


Free BrainMass Quizzes
Basic Networking Questions

This quiz consists of some basic networking questions.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

C# variables and classes

This quiz contains questions about C# classes and variables.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.