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
What is overriding in oops?
Give two or more real cenario of virtual function and vertual object
What is a function in oop?
Why is polymorphism important in oop?
What is class and object in oops?
What are benefits of oop?
write a program to find 2 power of a 5digit number with out using big int and exponent ?
What is encapsulation in ict?
What are functions in oop?
What is purpose of inheritance?
What are the 3 principles of oop?
What is static modifier?
any one please tell me the purpose of operator overloading
what is the drawback of classical methods in oops?
What is the types of inheritance?