Log In
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
1 vote

Which of the following is incorrect in C++?

  1. when we write overloaded function we must code the function for each usage
  2. when we write function template we code the function only once
  3. it is difficult to debug macros
  4. templates are more efficient than macros
in Object Oriented Programming
recategorized by

2 Answers

0 votes

ans should be none of these 

first 3 choices are correct and so is 4th

Templates undoubtedly take longer.

However, templates are significantly more powerful and obey C++ syntactical rules, whereas macros do not.

The reason Templates take longer is because you can have a template which is recursive, and all of those recurrences need to be generated. This is the foundation upon which looping constructs in Template Metaprogramming are built. Macros, in contrast, cannot call themselves, and are therefore limited to a single expansion.

0 votes

A function template by itself is not a type, or a function, or any other entity. No code is generated from a source file that contains only template definitions. In order for any code to appear, a template must be instantiated: the template arguments must be determined so that the compiler can generate an actual function (or class, from a class template).

Why do they have a bad reputation - hard to use well - most macro system are so simplistic they make it harder - difficult to debug.

Everyone knows f'n overloading.

d) just coz template takes more time.


Related questions

2 votes
1 answer
When the inheritance is private, the private methods in base class are _____ in the derived class (in C++) inaccessible accessible protected public
asked Jul 30, 2016 in Object Oriented Programming jothee 1.9k views
2 votes
3 answers
Which of the following, in C++, is inherited in a derived class from base class? constructor destructor data members virtual methods
asked Jul 30, 2016 in Object Oriented Programming jothee 1.2k views
4 votes
1 answer
Which one of the following is correct, when a class grants friend status to another class? The member functions of the class generating friendship can access teh members of the friend class All member functions of the class granted friendship have unrestricted access to the members of the class granting the friendship Class friendship is reciprocal to each other There is no such concept
asked Aug 14, 2016 in Object Oriented Programming jothee 2.6k views
2 votes
0 answers
Which of the following concepts of OOPS means exposing only necessary information to client? A. Encapsulation B. Abstraction C. Data hiding D. Data binding Answer is C, Why?
asked Jan 11, 2018 in Object Oriented Programming Manu Madhavan 311 views