answersLogoWhite

0

There is no such thing as a constructor function in C++ (constructors have no return value, not even void, and cannot be called like regular functions). Constructors are invoked rather than called directly, either by declaring a static variable of the class type, or via the C++ new operator.

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

True or False A C plus plus class constructor cannot return a function value?

True - A C++ constructor cannot return a value.


What is the difference between constructor and friend function in c plus plus?

A constructor is a method that fires when the object is instantiated. A friend function is a function that has special access to the object. They are two different types of things, and cannot be further differenced.


What is conustrutor?

A constructor is a function in C which has the same name of the class. The constructor can be used to initialize some function.


Can you write own constructor in c plus plus?

Yes.


What is the difference between implicit and explicit call of constructor in c plus plus?

An implicit constructor call will always call the default constructor, whereas explicit constructor calls allow to chose the best constructor and passing of arguments into the constructor.


What is the use of private constructor in c plus plus?

Private construction prevents objects from the class from being instantiated other than via a static member function of the class, a friend function or a friend class.


How constructor called?

You cannot invoke a constructor explicitly. It will get invoked implicitly when you call the new keyword on the class to create an object of the class. Ex: private ClassExample obj = new ClassExample(); here this new keyword usage on the ClassExample class will invoke the constructor of this class and create an object of that class.


What is difference constructor and function in programming C plus plus?

A Constructor is called when you are making a new instance of a class and member functions are functions that you can call within your class or else call using the instance of that class.for exampleclass Foo {public:int bar;Foo(int bar) {this->bar = bar;}inc_bar(); {this->bar++;}};Foo instance(10); // Constructor is called and bar is set to 10cout


What are the basics of main function in c and c plus plus?

The main function is the entry point of your application. Its primary purpose is to process command-line switches (if any) and to invoke the appropriate functions. For trivial applications the main function may be the only function, however separating blocks of code into re-usable functions make code much easier to read.


What is the first function executed in a C plus plus program?

For gcc there's a non-standard solution. Declare the function with __attribute__((constructor)) (note the double parentheses). Like this: void init(void) __attribute__ ((constructor)); void init(void) { // your code goes here } Starting with gcc 4.3 there's even a possibility to assign a priority to the "constructor". See http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html for details.


What are the building function in c plus plus?

There is no such term as "building function" in C++.


What is the method of constructor overloading in c plus plus?

Constructor overloading, just like any function's overloading, is where more than one configuration of parameters exists for the function. Based on the number and type of the parameters, different versions of the function can be resolved by the linker. This is typically used in the constructor as the default constructor (no parameters), the copy constructor (one reference parameter of the same type as the class), and the conversion constructor (any other combination of parameters).