edited by
1,810 views
0 votes
0 votes

Which of the following is not correct (in C++)?

  1. Class templates and function templates are instantiated in the same way
  2. Class templates differ from function templates in the way they are initiated
  3. Class template is initiated by defining an object using the template argument
  4. Class templates are generally used for storage classes
edited by

2 Answers

0 votes
0 votes
I think question is incomplete or incorrect as options 2,3 & 4 are not correct here. Only 1 is correct as both class templates and function templates are instantiated in the same way.

//Defines a template for a class that can hold two objects.
template<typename T1, typename T2>
struct pair {
    T1 first;
    T2 second; };
//Defines a template for a function that gives the minimum of two values.
template<typename T>
T min(T a, T b) {
    return a < b ? a : b; }

Class templates can be used to write programs that execute at compile time and here we can see template instantiations with pattern matching as pure functions.
0 votes
0 votes
In C++ class template and function template are similar in the way the are initiated.
Class template are not used for storage class. Class templates and function templates are instantiated in the same way and Class template is not initiated by defining an object using the template.

So (2), (3), (4) are not correct in C++.
So, option (C) is correct.
Answer:

Related questions

1 votes
1 votes
2 answers
1
Arjun asked Nov 5, 2017
3,067 views
Which speed up could be achieved according to Amdahl's Law for infinte number of processes if $5\%$ of a program is sequential and the remaining part is ideally parallel?...
0 votes
0 votes
1 answer
2
Arjun asked Nov 5, 2017
2,519 views
Which of the given wireless technologies used in IoT, consumes the least amount of power?ZigbeeBluetoothWi-FiGSM/CDMA
0 votes
0 votes
2 answers
3
Arjun asked Nov 5, 2017
4,592 views
Which of the following is not a Clustering method?K-Means methodSelf Organizing feature map methodK- nearest neighbor methodAgglomerative method