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() {}
};
A friend constructor is a constructor that is declared a friend of another class and that grants that constructor private access to the class in which it is declared a friend. Example: class Y { friend char* X::foo (int); // friend function friend X::X (char); // constructors can be friends friend X::~X(); // destructors can be friends }; For more information, see '11.3 Friends' in the current ISO C++ Standard.
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.
Not possible in C.
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.
True - A C++ constructor cannot return a value.
A constructor is a function in C which has the same name of the class. The constructor can be used to initialize some function.
There is no such thing as a default parameterized constructor. The default constructor is always the 'no-arg' constructor and does not take any parameters or arguments as input
question i understand not
Not sure what you mean by this. C is a not an object-oriented programming (OOP) language, and therefore has no constructor concept. You probably meant C++ but, even so, there is no "rise of constructor concept". Constructors are fundamental to OOP -- they allow you to initialise an object at the point of instantiation.
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.
When any constructor is deffined in your class, the java compiler create a default no argument constructor for you. This constructor only have an invocation to the super class constructor (" super( ) ").
Any constructor that can be invoked without explicitly passing any arguments is a default constructor. Note that there can be only one default constructor so there can only be one constructor where all arguments have default values or one constructor that has no arguments, but not both. A constructor where all arguments have default values is a useful means of combining two or more constructors into a single default constructor, thus reducing verbosity and code duplication.