can inline function declare in private part of class?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

what are the realtime excercises in C++?

2333


What is overloading in oop?

572


What are the three main types of variables?

600


What are the 4 main oop principles?

680


I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...

1622






Which language is not a true object oriented programming language?

640


What is polymorphism used for?

566


How does polymorphism work?

635


What is multilevel inheritance explain with example?

623


What is abstraction in oops?

584


What is the types of inheritance?

602


if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?

2753


What is object in oop with example?

697


What is the real time example of inheritance?

637


What is the fundamental idea of oop?

634