answersLogoWhite

0


Best Answer

A constructor is not a function. A function is a type, as specified by its return type, and must return a value of that type unless the type is void. A constructor does not return anything, not even void.

The purpose of a constructor is to both allocate and initialise memory for an object of the type being constructed. If a valid object cannot be constructed for any reason, the constructor must throw an exception. If the object's class has no data members (attributes), the class does not require a constructor. This is typically the case for most abstract data types and base classes which are used purely as interfaces.

Constructors differ from functions in that all constructors have an initialisation section that is used specifically to initialise non-static data members. The body of the constructor is rarely used except to perform initialisations that cannot be more easily performed by the initialisation section.

A class may have more than one constructor to provide alternative methods of construction based upon the number and type of arguments supplied (if any). When no arguments are required or all arguments have default values then the constructor is known as the default constructor. If the constructor has only one argument the constructor is known as a conversion constructor (because the argument is converted to an object of the class). However, if the constructor argument is a constant reference to an object of the same class, then it is known as a copy constructor, and when the constructor argument is an rvalue reference, it is known as a move constructor. If copy and/or move constructors are provided for a class, the equivalent assignment operators should also be provided for that class. All other constructors are known as user-defined constructors.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

The properties of a class are its member methods (functions and operators). The member data are known as the attributes of the class.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the properties of class in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What supports reusability and extensibility of classes in c plus plus?

There are two ways to reuse a class in C++. Composition and inheritance. With composition, any class data member can be an instance of an existing class. With inheritance, we can derive a new class from an existing class. Either way, we create a new class of object with all the properties of the existing class which can be extended and/or replaced with properties of our own.


Can a c plus plus class be derived from a Java class?

No.


What is the role of object in c plus plus?

An object in C++ is an instance of a C++ class.


How can you store Class properties in Array in c?

Yes, you can create array that will store class properties. But all of them have to be of the same type.


What is nested class in c plus plus?

s.


What is the unit of programming in c plus plus A. Function B. class C. object D. Attribute?

B. Class.


How can you store Class properties in Array in c sharp?

vcbvcbcvb


Can you use c in c plus plus without using class and object?

Sure.


What is a method in c plus plus?

In C++, methods are simply class member functions.


How do you create a class in C plus plus?

class class_name { private: data_members; public: member_functions; };


What is object in c plus plus?

An object is simply an instance of a class.


What are the abstract datatypes in c plus plus?

Class Object Message