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 3 pillars of oop?

876


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.

2004


Who invented oop?

850


What is inheritance in simple words?

827


What is the main feature of oop?

909


What is overloading in oop?

773


What type of loop is a for loop?

873


What are the three parts of a simple empty class?

1777


What is purpose of inheritance?

864


is there any choice in opting subjects like 4 out of 7

1942


What is super in oop?

856


What is encapsulation in oop?

799


What are the three main types of variables?

839


What is difference between data abstraction and encapsulation?

847


What is encapsulation example?

779