?
Solved

difference between macro, inline and Template

Posted on 2004-09-09
5
Medium Priority
?
808 Views
Last Modified: 2008-02-01
Hi
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.
Regards
Gaurav
0
Comment
Question by:nclgaurav
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 12018987
nclgaurav,
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.
nclgaurav,
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.
0
 
LVL 2

Expert Comment

by:guntherothk
ID: 12027529
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.
0
 
LVL 30

Expert Comment

by:Axter
ID: 12027709
nclgaurav,
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:
CBAB

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.
0
 

Author Comment

by:nclgaurav
ID: 12032606
thats fine Dear experts.From nowonwards, I will close my ask questions.For my past history, I can't do anything except saying sorry.
Regards
0
 
LVL 4

Accepted Solution

by:
pankajtiwary earned 150 total points
ID: 12041571
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.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question