answersLogoWhite

0


Best Answer

When used correctly and for the purpose intended there are no disadvantages to templates. Templates are type-safe, can be debugged by the compiler and make it easier to write functions and classes that operate upon a type without the need to write duplicate code by hand. If you're using templates for any other purpose then there will obviously be disadvantages. However, when you consider the alternatives, macros are disadvantageous because they are not type-safe, cannot be debugged by the compiler and are always inline expanded (which is not always a good thing), while coding by hand is disadvantageous because it introduces duplicate code and increases the maintenance cost of that code. All three methods have their uses, but when used incorrectly you will always find disadvantages. That is not the fault of the methods themselves, that is the fault of the programmer.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Disadvantages of template in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What has the author Mark Nelson written?

Mark Nelson has written: 'C++ programmer's guide to the standard template library' -- subject(s): C++ (Computer program language), Standard template library, C. 'C [plus plus] programmer's guide to the Standard Template Library' -- subject(s): C.


What is default name of c plus plus?

If you mean the original name of C++, it was originally called "C with Classes". However, after the introduction of template metaprogramming, it was renamed C++ which meant "the successor to C".


What has the author David Vandevoorde written?

David Vandevoorde has written: 'C [plus plus] templates' -- subject(s): C 'C++ templates' -- subject(s): C++ (Computer program language), Microsoft Visual C++, Standard template library


What is a delegate in C plus plus?

C++ does not have built-in support for delegates, however it is possible to simulate delegation through the use of template hacks. See related links below for more information.


How you describe operations of stack ADT using c template functions?

No, because C does not support the concept of template functions. Template functions only exist in C++, never in C.


What is the differnce between ordinary function and template function of c language?

The c language does not have template functions. That is a c++ thing.


How do you add a template to your HTML website in Notepad plus plus?

You can add a template to your HTML website in Notepad plus plus by adding a zen coding plugin in the notepad plus plus.


What is STL in c plus plus?

Standard Template Library. The STL basically provides templates for common containers, such as lists and queues, as well as functions, iterators and algorithms.


What is the c plus plus standard template library package you call to use the console for input and output?

The Standard Template Library does not provide routines or packages for I/O. You are probably thinking iostreams library, using cin and cout, which is part of the RunTime Library, but not part of the STL.


How to write C plus plus Program to take 2 distant values as argument and return the larger value on the screen?

Use the following template function: template<class T> T& max(T& x, T& y){return(y<x?x:y;}


Disadvantages of c plus plus over c?

There are no disadvantages as such since everything you can do in C you can also do in C++, with relatively minor alterations to conform with C++'s stricter type safety. C++ essentially inherits all that is good about C, and attempts to fix all that is bad without overly compromising backward compatibility, as well as adding object-oriented programming support, which constitutes the major difference between C and C++.


What are the Advantages of c over c plus plus?

There are no advantages of C over C++ as such. Everything you can do in C you can also do in C++. However, by taking advantage of C++ object oriented programming, generic programming and template meta programming as well as C-style coding, you can produce more efficient machine code far more easily and more quickly than with C alone.