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
Can we create object of interface?
What is the purpose of enum?
explain sub-type and sub class? atleast u have differ it into 4 points?
what's the basic's in dot net
is there any choice in opting subjects like 4 out of 7
State what is encapsulation and friend function?
What is the highest level of cohesion?
What makes a language oop?
What are benefits of oop?
What is inheritance write a program to show use of inheritance?
write a program to find 2^n+1 ?
What is abstraction in oops with example?
what type of questions
What is overloading and its types?
Why is polymorphism used?