Inline function question
Aug 27, 2014 at 4:27pm UTC
Hi
in the code below, the function someFunc can't be inline function and the function otherFunc can be inline. someone can explain why?
1 2 3 4 5 6 7 8 9 10
struct Base1{
virtual void foo(){}
};
struct Derived1: Base1{
void foo(){}
};
void someFunc(Base1* obj){ obj->foo(); }
void otherFunc(){ Derived1 s; s.foo(); }
Aug 27, 2014 at 4:33pm UTC
Did you tell the compile that you you want it inlined?
1 2
inline void someFunc(Base1* obj){ obj->foo(); }
inline void otherFunc(){ Derived1 s; s.foo(); }
Note that this won't guarantee that it is inlined. It's just a hint.
Aug 27, 2014 at 4:56pm UTC
yes i inlined those functions and when i call them in main() the first function show error and the second is fine
i dont know why the first cant be inlined
Topic archived. No new replies allowed.