can inline function declare in private part of class?
Answer / 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 |
WRITE A SIMPLE C++ PROGRAM TO SWAP TWO NOS WITHOUT USING TEMP
What is object in oop with example?
What is abstraction with example?
Write a program to demonstrate the use of 'Composition' in C++
What is oops in simple words?
Why is encapsulation used?
What is object in oop?
Why multiple inheritance is not possible?
WHAT'S THE OOPS BASIC OOPS CONCEPTS IN DOTNET
Which keyword is written to use a variable declared in one class in the other class?
What is debug class?what is trace class? What differences are between them? With examples.
In multilevel inheritance constructors will be executed from the .... class to ... class