class A
{
int c;
public:
inline int func(int a,int b)
{
c=a+b;
}
};
int main()
{
A a;
int (*p)(int,int); //function pointer
p=&(a.func);
}
//in general if compiler sees the inline type it copies the declaration,arguement,return types and method body into symbol table.
but in the main we need to store the address of func then what does the compiler do?? does it remove the code from symbol table and give memory to that inlne function as it does for mon-inline functions and place that code in that address??
but in the main we need to store the address of func then what does the compiler do??
Well, for starters, it won't compile because...
p=&(a.func); <-- this is not legal in C++
But assuming it was legal... the inline keyword is just a suggestion. In this case, the function will be callable and the function pointer would point to the body of that function just as if it were not inline.
Of course.. just because the function is not inlined in this case does not mean it can't be inlined when it is called directly.