Inline function and classes in C++:
All the functions defined inside the class are implicitly inline.
class A
{
public:
inline int square(int a)
{
return a*a;
}
};
int main() {
A ob;
cout<<ob.square(6);
}
Explicitly Defined:
class A
{
public:
int square(int a) ;
};
inline int A:: square(int a)
{
return a*a;
}
int main() {
A ob;
cout<<ob.square(6);
}
No comments:
Post a Comment