| |
GeekInterview.com > Interview Questions > Concepts > OOPS
| Print | |
Question: What are enumerators? and what are in-line functions? giv ans with eg.
|
| January 01, 2008 05:32:33 |
#2 |
| inbox4rakesh |
Member Since: January 2008 Total Comments: 2 |
RE: What are enumerators? and what are in-line functions? giv ans with eg. |
Enumerators: Enumerators are a way to give related constants a human understandable name for better code readability. For example:
We can use the following statement to check whether the connection to an SQL Server is open or not with the following statement
if(cnConnection.State ==1) { //Code to be executed when the connection is open }
However, the following code makes it more readable,
if(cnConnection.State ==ConnectionState.Open) { //Code to be executed when the connection is open }
Enumerators are declared in the following way (The syntax may differ from language to language):
public enum <enumName>{name1,name2,name3,...}
example:
public enum DAYS { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday};
Inline Functions: Generally, during the execution of a program whenever a call to a function is encountered, the control switches from current execution to the method and vice versa. This impacts the overall performance of code execution. In order to remove this switching, Inline functions are used. It is made possible in the following way:
Whenever, the program gets compiled the inline functions get inserted at the calling location so that the execution does not switch in memory locations, and thus improving the program performance.
As already mentioned in the previous thread by Kamal, this is a compiler specific option. |
| |
Back To Question | |