Question
#include <iostream>
using namespace std;
class sample
{
public:
sample(int i) : m_i(i) { }
public:
int operator()(int i = 0) const
{
return m_i + i;
}
operator int () const
{
return m_i;
}
private:
int m_i;
friend int g(const sample&);
};
int f(char c)
{
return c;
}
int main()
{
sample f(2);
cout << f(2);
return 0;
}
a.
3
b.
4
c.
5
d.
None of the mentioned
Posted under Object Oriented Programming Using C++
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of this program?
Similar Questions
Discover Related MCQs
Q. How types are there in user defined conversion?
View solution
Q. Pick out the correct syntax of operator conversion.
View solution
Q. Which rule will not affect the friend function?
View solution
Q. Which keyword is used to declare the friend function?
View solution
Q. What is the syntax of friend function?
View solution
Q. Pick out the correct statement.
View solution
Q. Where does keyword ‘friend’ should be placed?
View solution
Q. How to store the large objects in c++ if it extents its allocated memory?
View solution
Q. When we are using heap operations what do we need to do to save the memory?
View solution
Q. Which container in c++ will take large objects?
View solution
Q. How to stop your program from eating so much ram?
View solution
Q. Which option is best to eliminate the memory problem?
View solution
Q. What is the size of the heap?
View solution
Q. How to unlimit the size of the stack?
View solution
Q. In linux, how does the heaps and stacks are managed?
View solution
Q. Which is used to pass the large objects in c++?
View solution
Q. What are the essential operators in c++?
View solution
Q. In which direction does the assignment operation will take place?
View solution
Q. Pick out the compound assignment statement.
View solution
Q. What is the associativity of add(+);
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!