can inline function declare in private part of class?



can inline function declare in private part of class?..

Answer / meet

yes, inline functions can be declared in the private section of class. But why would you want it? small functions should be made inline and function defined inside the class are implicitly inline. if you keep inline function private it is must to provide public method (interface) that internally calls inline function.
Consider this:
#include <iostream>
using namespace std;
class PrivateInlinefunction {
int s;
void display();
public:
PrivateInlinefunction()
{
s=9;
}
void demo()
{
display();
}
};
inline void PrivateInlinefunction::show()
{
cout<<s<<endl;
}
int main()
{
Test* t=new Test;
t->demo();
delete t;
t=0;
return 0;
}

Private inline functions are almost never required. But you can make them as private or protected.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More OOPS Interview Questions

what is a ststic variable and stiticfunction briefly explain with exmple and in which case we use

2 Answers   HCL,


what is the difference between class and structure in C++?

9 Answers   Aspire, IBS, TCS,


can inline function declare in private part of class?

1 Answers  


write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.

0 Answers   Wipro,


What is protected in oop?

0 Answers  






i got a backdoor offer in process global,Bangalore..Can i work with it?

0 Answers  


Finding of the 4 larger (bigger) numbers from the list like{1245,4587,2145,1163,29987,65783.....}

1 Answers   Wipro,


what are the ways in which a constructors can be called?

2 Answers   TCS,


tell about copy constructor

3 Answers   Siemens,


Plese get me a perfect C++ program for railway/airway reservation with all details.

0 Answers   ITM,


what are the uses of C++

1 Answers  


What are the important components of cohesion?

0 Answers  


Categories