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 an advantage of polymorphism?

0 Answers  


What is Hashing and how is it done? Pictorial form?

2 Answers   emc2, Wipro,


Why is polymorphism important in oop?

0 Answers  


what uses of c++ language?

3 Answers  


What is abstraction example?

0 Answers  






Can we have inheritance without polymorphism?

0 Answers  


What is the difference between static polymorphism and dynamic polymorphism?

0 Answers  


Precompilation ?

1 Answers   emc2,


assume the program must insert 4 elements from the key board and then do the following programs.sequential search(search one of the elements),using insertion sort(sort the element) and using selection sort(sort the element).

0 Answers  


What is for loop and its syntax?

0 Answers  


explain defference between structure and class with example

1 Answers  


2. Give the different notations for the class.\

0 Answers  


Categories