A "normal" function is just a function. Even a friend function is just a normal function. However, when a class declares an external function or an external class method to be a friend of the class, the friend function gains access to the private members of the class.
class foo {
friend void bar(foo&);
int m_data;
};
void bar(foo& f)
{
f.m_data=42;
}
In the example above, the foo class declares the bar function to be a friend function. As such, the bar function has unrestricted access to the private members of foo. In this case, foo::m_data is private (by default) and would therefore be inaccessible to bar were it not declared a friend of foo. Other than that, the bar function is no different to any other function.
Note that you cannot declare friendship from outside of a class. The class itself must declare its own friends. However, the same function can be declared friends in more than one class, which can be a useful feature when two or more classes work closely together, as the friend function can be used to provide the "glue" that binds them together.
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.
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.
Only that they cannot be inherited by derived classes. This is "a good thing". Other than that, a friend function has full access to a class' private and protected members and you cannot limit its scope. At this data hiding feature of c++ is broken.
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.
...a function call.
Something like this:
yes,we can make function inline
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.
The keyword "friend" allows a function or variable to have access to a protected member inside a class.
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.
There is no such term as "building function" in C++.
cot(A+B+C) is, itself, a trigonometric function, so the question does not really make any sense!
Yes, there can be friend functions in C++.
Only that they cannot be inherited by derived classes. This is "a good thing". Other than that, a friend function has full access to a class' private and protected members and you cannot limit its scope. At this data hiding feature of c++ is broken.
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.
...a function call.
C++ is easier to use as you have to learn slightly less and script slightly to make your function(s) work.