well, Inline Class is the reverse of Extract Class. Inline Class if a class is no longer pulling its weight and shouldn't be around any more. Often this is the result of refactoring that moves other responsibilities out of the class so there is little left. Then I want to fold this class into another class, picking one that seems to use the runt class the most.
A class which is define inside a class is known as inner class inner class can be static but top level class can not be static.
A function defined in the body of a class declaration is an inline function.
In the following class declaration, the Account constructor is an inline function. The member functions GetBalance, Deposit, and Withdraw are not specified as inline but can be implemented as inline functions.
/ Inline_Member_Functions.cpp
c lass Account
{
public:
Account(d ouble initial_balance) { balance = initial_balance; }
double GetBalance();
double Deposit( double Amount );
double Withdraw( double Amount );
private:
double balance;
};
inline double Account::GetBalance()
{
retu rn balance;
}
inline double Account::Deposit( double Amount )
{
return ( balance += Amount );
}
inline double Account::Withdraw( double Amount )
{
return ( balance -= Amount );
}
int main()
{
}
NoteNote
In the class declaration, the functions were declared without the inline keyword. The inline keyword can be specified in the class declaration; the result is the same.
A given inline member function must be declared the same way in every compilation unit. This constraint causes inline functions to behave as if they were instantiated functions. Additionally, there must be exactly one definition of an inline function.
A class member function defaults to external linkage unless a definition for that function contains the inline specifier. The preceding example shows that these functions need not be explicitly declared with the inline specifier; using inline in the function definition causes it to be an inline function.
Answered by
Romi
, an ibibo Master,
at
11:39 AM on July 10, 2008