• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 817
  • Last Modified:

difference between macro, inline and Template

What the difference between Macro and Inline.Which one has to use when?
What is the difference  of Macro and Template?
What is the difference between Inline and Template?
Plesase tell me with some example.
1 Solution
I see that you have open questions that have been abandon.

Please close your questions by awarding points, or requesting deletion of the question.

You also have the following negative feedback:
This Member has failed to responded to Expert comments, has ignored cleanup notices, and has abandoned this question.
To avoid negative feedback in the future, please read this carefully: http:help.jsp#hs5

Experts will be hesitate to help you if they see that you fail to clean up your questions, or fail to provide proper grading.

Also, please read the guide lines for assigning points to a question.
Thanks for letting the experts know axter. The experts exchange is a community. It's not free help. Users who don't want to contribute at least by closing their questions should find another place to go for help.
At first glance it looks like you have a good grading history, but after looking at the graded questions, it shows that you have only graded 4 questions that have points assigned.
All the other graded questions have either zero points assigned, or have been force accepted by a moderator and given an A grade.

Looking at the 4 questions you graded, you have the following grading history:

That's very poor, considering all the questions only have 50 points, and the experts gave you more  then 50 points worth.

Experts will hesitate to help a questioner that gives poor grades.

This question is not a 50 point question.  However, many experts will still give a good detailed answer to a 50 point question if the questioner has a good grading history.

If you can not spend a little time cleaning up your open questions, then experts are not going to waste time helping you in your new questions.
nclgauravAuthor Commented:
thats fine Dear experts.From nowonwards, I will close my ask questions.For my past history, I can't do anything except saying sorry.
Q: What the difference between Macro and Inline.Which one has to use when?
A: A macro is a function like entity which gets substituted with the actual code at the time of preprossing. The basic problem is since the compiler doesn't see any macros but just the substituted text so it has no idea of where the substituted text come from. Since it is normal substitution, no type chacking is done. This is fast but dangerous. C++ almost advices not to use it.
An inline is actually a normal funation whose code is actually substituted in the place where the function is called. The inline functions are superior to macros in the sense at the time of compilation, the parameters and the return type are checked everytime the function is getting called inside the source code. But here again its just the substitution of code but at the compiler level.

Q: What is the difference  of Macro and Template?
A: A macro is as defined above where as a template is a construct used in C++ for generic programming. A template can be used for generic class and functions. Anywhere the function with some type is called or a class with the possible type is made, the compiler generated the code for that particular function/class. Here also a proper type checking is done and the code is generated for all the possible calls.

Q: What is the difference between Inline and Template?
A: Inline is only used for functions whereas a template may be a class or a function. Don't confuse between inline and a template. Both are totally different beasts. You can take an inline as not a function call but substitution of function code at the desired places. A template, on the other hand, is just a skeleton defined by you on the basis of which the code for the appropriate type may be generated.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now