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 R T T I ?

6 Answers   Ness Technologies,


In which cases you use override and new base?

2 Answers  


What do you mean by abstraction?

0 Answers  


Explain virtual inheritance?

0 Answers  


What is a superclass in oop?

0 Answers  






what is overloading and overriding?

7 Answers  


who is the father of OPPS

4 Answers   Infosys, TCS,


Which language is pure oop?

0 Answers  


What is the difference between a mixin and inheritance?

0 Answers  


What is a mixin class?

4 Answers  


what is virtual function?

3 Answers  


Why and when is a virtual destructor needed?

5 Answers  


Categories