What are enumerators? and what are in-line functions? giv ans with eg.

Questions by vinayakpalande

Showing Answers 1 - 6 of 6 Answers

enum's are data type, while in-line functions are function.
enum are integer repesentation in understandable form like-
enum {
monday,
tuesday,
...
...
sunday
};

now if compare like
if( 1== sunday) condition will return true.


in-line functions are the ones which get insert into the code where they are called.
The difference between function and in-line function is no call will be made to the in-line function during execution. using this one can improve execution performance. this capability is compiler dependent and also depend on the optimization settings.

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.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions