What are the advantages and disadvantages of using inline
and const?
Answer Posted / vivek mahto
Well for the inline..
Advantages-
inline is a compiler directive so it will make compiler to copy the whole function where it is required , So there is no stack frame required in the stack section for storing the address of the function .
Disadvantages-
inline should only be used for the long functions as it will require more space as well as more calculation time.
For the const...
Advantages--
If you want any variable to keep constant through out the program then you can use const keyword. It is stored in the read only of the initalized data segment , even the pointer storing it's location cannot change the value of it, pointer can just change the address to point at some other location.
Disadvantages--
As the const is not flexible so mostly people use #define which is more flexible than const
| Is This Answer Correct ? | 5 Yes | 1 No |
Post New Answer View All Answers
Which is better turbo c++ or dev c++?
Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list
What is helper in c++?
what is Member Functions in Classes?
How would you use qsort() function to sort an array of structures?
Tell me an example where stacks are useful?
Why was c++ made?
What is the main use of c++?
Is the declaration of a class its interface or its implementation?
What is ostream in c++?
Define a conversion constructor?
Why c++ is created?
Is c++ proprietary?
If dog is a friend of boy and boy is a friend of house, is dog a friend of house?
Can static member variables be private?