What are inline functions?
Answers were Sorted based on User's Feedback
Answer / roshanpr
Functions that are expanded inline ( that we during there
call) is called inline functions.
Usually when there there is a function call the control is
taken to the function definition where the code is executed
and then the control returns back to main. But in case of
inline function there is no jump in the flow, rather the
function it self is expanded at the place of call.
You can make function inline in two ways.
1) Prefixing keyword "inline" durin the function
declaration.
2) By defining the function inside the class declaration
Ex: shows both the implementation
Class myClass
{
int age;
public:
inline void getAge();
void showAge()
{
cout<<"Age:"<<age;
}
};
void myClass getAge()
{
cout<<"Age:"<<age;
}
Is This Answer Correct ? | 11 Yes | 1 No |
Answer / laxman
Inline function :-
In genereal function call branching method is there . In
inline function substitution takes place . Inline
functions are expanded during compilation . Exectution
becomes fast and branching is eliminated. Inline word is a
request but not command. If inline is not possible compiler
takes it like a genral function call.
rules:
1 function should be small
2. Controll statements are not valid like for ,while
if u need more mail to me
Is This Answer Correct ? | 6 Yes | 2 No |
Difference between Abstraction and encapsulation in C++?
Difference between a copy constructor and an assignment operator.
If there are two catch statements, one for base and one for derived, which should come first?
Do class method definitions?
Write a program for Divide a number with 2 and Print the output ( NOTE: Check for divide by zero error).
class Foo { const int x; protected: Foo(int f); ~Foo(); }; Foo f; Referring to the sample code above, why will the class declaration not compile? a) The variable x is const. b) The destructor is protected. c) The destructor is not public. d) The constructor is protected. e) There is no default constructor.
What is the identity function in c++? How is it useful?
What is low level language in simple words?
Describe delete operator?
If a base class is an adt, and it has three pure virtual functions, how many of these functions must be overridden in its derived classes?
What is a storage class? Mention the storage classes in c++.
How new/delete differs from malloc()/free?