answersLogoWhite

0


Best Answer

Class initialisation is normally handled by the class constructor(s). Every constructor has an optional initialisation section between the declaration and the body of the constructor. This is generally used to call specific base class constructors, but can be used to initialise any member variables via their own constructors. Member variables may alternatively be initialised in the body of the constructor, but this is really only necessary when member pointers need to be allocated new memory. For those classes that have many members and many constructors, the initialisation may be handled by a private member method called by each constructor in order to simplify maintenance during development. However, when the class is finalised, the private member method will generally be replaced with formal initialisation sections in each constructor.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: In C plus plus What function is called to initialize a class?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is member fusion in c plus plus?

If you are asking about member functions. When we declare a function inside a class then that function becomes member function of that class and this function can access the whole class


What function initializes variables in a class?

you have to initialize it into the "Constructor" which is a function without dataType and it's name is the same with the class nameEX:-class Exforsys{private:int a,b;public:Exforsys();...};Exforsys :: Exforsys(){a=0;b=0;}the EX from : http://www.exforsys.com/tutorials/c-plus-plus/class-constructors-and-destructors-in-c.htmlI recommend this link for You Under the title "Constructors and destructors" :http://www.cplusplus.com/doc/tutorial/classes/You can also See : http://www.win.tue.nl/~maubach/university/education/online-references/cpp/swartz/notescpp/oop-condestructors/constructors.html


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.


Why can't the accessor member function change any of the values in a class in C plus plus?

Nothing stops a member function from changing any of the values in a class. By convention, an accessor function is used to give read only access to class data, but that does not mean that it is prohibited from doing so. It is a member function, after all, and it has all the rights of any member function of the class.


What is self referential function in c plus plus?

A self-referential function in C++, or in any other supporting language, is a recursive function.

Related questions

What is member fusion in c plus plus?

If you are asking about member functions. When we declare a function inside a class then that function becomes member function of that class and this function can access the whole class


What function initializes variables in a class?

you have to initialize it into the "Constructor" which is a function without dataType and it's name is the same with the class nameEX:-class Exforsys{private:int a,b;public:Exforsys();...};Exforsys :: Exforsys(){a=0;b=0;}the EX from : http://www.exforsys.com/tutorials/c-plus-plus/class-constructors-and-destructors-in-c.htmlI recommend this link for You Under the title "Constructors and destructors" :http://www.cplusplus.com/doc/tutorial/classes/You can also See : http://www.win.tue.nl/~maubach/university/education/online-references/cpp/swartz/notescpp/oop-condestructors/constructors.html


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

B. Class.


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.


Definition of operator overloading inc plus plus?

to define an additional task to an operator ,we must specify what it means in relation to the class to which the operator is applied.this is done with the help of a special function called operator function ,which describes the task.


Why can't the accessor member function change any of the values in a class in C plus plus?

Nothing stops a member function from changing any of the values in a class. By convention, an accessor function is used to give read only access to class data, but that does not mean that it is prohibited from doing so. It is a member function, after all, and it has all the rights of any member function of the class.


What is self referential function in c plus plus?

A self-referential function in C++, or in any other supporting language, is a recursive function.


Which C plus plus keyword allows a function outside of a class to access private class members?

The keyword is friend. The external function must be declared a friend of the class (from within the class itself) in order to become a member of the class and thus gain access to the private (and protected) members of the class.


What is message passing in c plus plus?

-define class with necessary data member & member function. -create object of that class. -communication.


What is a main function in c plus plus?

It is the first function that gets called when the program is executed.


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

There is no such thing. When declaring a friend function only the explicitly-scoped friend is granted private access. The friend function may well be declared virtual within its own class but none of its overrides are granted access unless they are explicitly granted access.


What is friendly in c plus plus?

The keyword "friend" allows a function or variable to have access to a protected member inside a class.