answersLogoWhite

0

question i understand not

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Can you define the constructor as private?

Yes, you can. Making a constructor private ensures that no other class can instantiate that class you just created with a private constructor. It is usually used in Singleton Patterns.


What are different type of constructor in java?

Every class, including abstract classes, MUST have a constructor. The different types are: a. Regular constructors b. Overloaded constructors and c. Private constructors


Can you implement a constructor in private part of code?

no we cannot initialize a constructor in private in order to call a constructor from outside of a class it must be a public member.in order to create an object we should call the constructor .so only private members can implement outside of the class.


Can you declare constructor as a private in c plus plus?

Yes. However, like any other private member, a private constructor can only be accessed by the class itself (typically via a static member function) or by one of its friends. There are very few cases where private constructors are appropriate, one of the most common being the need to suppress the compiler-generated copy construction of a base class. However, since C++11, suppressed constructors can simply be deleted, thus making error messages much more meaningful to users of your class. For example, instead of the following: class A { public: A (); // default constructor private: A (const A&); // suppress copy constructor (can still be invoked by the class and its friends) // ... }; You'd now use the following: class A { public: A (); // default constructor A (const A&) =delete; // suppress copy constructor (cannot be invoked at all) // ... };


Does java class must have public method?

no you can have a class with no public methods and even with a a private constructor public class Example { //constructor private Example(){ } }


When you go for private constructor?

jacks mums fit!


Constructor and destructor invocation in c?

Not possible in C.


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.


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.


Is there any friend constructor in c?

C is not an object-oriented programming language so there is no friend keyword let alone friend constructors. In C++, however, constructors can be declared friends. Consider the following code where the class Y default constructor has private access to X::foo() because the Y::Y() constructor is explicitly declared a friend of class X. Note that Y must be defined before X can be defined, thus X must be forward declared. #include<iostream> class X; // fwd declaration class Y { public: Y() { X x; x.foo(); } // X::foo is private, but Y::Y() is a friend. }; class X { friend Y::Y(); // friend constructor private: void foo() {} };


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.


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.