answersLogoWhite

0


Best Answer

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.

User Avatar

Wiki User

โˆ™ 2012-03-25 21:18:44
This answer is:
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
User Avatar
Study guides
๐Ÿ““
See all Study Guides
โœ๏ธ
Create a Study Guide

Add your answer:

Earn +20 pts
Q: What is the difference between constructor and friend function in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is friend constructor?

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.


What is the difference between friend function and normal member function?

We can access a Friend function from any other class in which friend function is introduced or declared even if the other class is not a member of first class. But when we use normal member function, we can have its access only in the derived classes of the first class. This is the basic difference between a friend function and a normal member function.


Can the constructor be declared as private in a class?

Yes, a constructor can be declared private in a class. However, in order to instantiate the class, you must include a static member function, a friend function or a friend class. The latter is often the preferred method.


What is the difference between friend function and virtual function?

A virtual function is a base class function that can be overridden by a derived class. A friend function is a non-member function that has private access to the class representation.


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

Everything: they are absolutely unrelated.


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.


Difference between member function and friend function?

A member function is the one which defined inside a class and is a member of the class. It may be private or public. While we can use friend function in the case when we want to one class to communicate with other class.


Why a friend function cannot be used to overload the assignment operator?

Assignment(=) operator is a special operator that will be provided by the constructor to the class when programmer has not provided(overloaded) as member of the class.(like copy constructor). When programmer is overloading = operator using friend function, two = operations will exists: 1) compiler is providing = operator 2) programmer is providing(overloading) = operator by friend function. Then simply ambiguity will be created and compiler will gives error. Its compilation error.


What is difference between friend function operator overloading and member function operator overloading?

While overloading operators using member function it takes only one arguments(other pass implicitly)... but in case of friend fuction two parameters are required..


What is the difference between a friend and a good friend?

a friend will go to dinner. a good friend will bury a body.


What is the difference between C and java?

Java is pure object oriented language, and C++ is not, because you can access the private member of classes in c++ by using the friend function. There is no such function within java.


What is the difference between boy friend best friend?

they both ur homies


What is the difference between a partner and a good friend?

Privileges


What is the difference between the movie and play versions of Oleanna?

big difference my friend


What is the difference between God and an imaginary friend?

God is real.


What is the meaning difference between the words girlfriend and girl friend?

girl friend is a friend that is girl and not a best friend and girl friend is best friend


What is the difference between a fan and a friend on Facebook?

if you are a friend you can look at their profile. if you are a fan... i dont know


What is the difference between close friend and best friend?

a close friend is someone you can talk to, and do things with. A best friend is someone you can tell anything to.


How do you tell the difference between a friend and love hug?

Youll know.


What is the difference between be and become?

He come back.He become my friend now .


Whats Difference between friend and girlfriend?

Girlfriend/Boyfriend is someone you have sex with, a friend is someone who has a friendship with you.


What is the difference between strangers and friends?

A friend is a family member that you have chosen and a stranger is a friend that you have not met yet.


How do you tell the difference between friends and lovers?

How they introduce them. Friend: "This is my friend, so and so" Lover: "This is my, um, friend, so and so"


What is the difference between friend with courage and a friend of the court?

Friends are friends. But friends have different qualities, you know which friend to turn to at what point.


What is the difference between a lady friend and girl friend?

lady friend is just a friend girlfriend is a relationship or where he just wants to get her in bed and make love