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 polymorphism programming?
Why is there no multiple inheritance?
i am getting an of the type can not convert int to int *. to overcome this problem what we should do?
What is encapsulation process?
Why is encapsulation used?
given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy
Can we create object of interface?
What are functions in oop?
write a program that takes input in digits and display the result in words from 1 to 1000
How can you overcome the diamond problem in inheritance?
Templates mean
What is object in oops?
What is encapsulation in oop?
What is object-oriented programming? Webopedia definition
What is the purpose of enum?