search
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
0 votes
1.4k views
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 templates is initiated by defining an object using the template argument.

4) Class templates are generally used for storage classes.
in Object Oriented Programming
recategorized by
1.4k views

1 Answer

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.

Related questions

0 votes
1 answer
1
311 views
Which of the following is true? (A) A static member of a class cannot be inherited by its derived class. (B) A static member of a class can be initialized only within the class it is a member of. (C) A static member of a class can be ... Since static member of a class is actually a global element, it does not require a class/object qualifier to access it independently of class/object.
asked Sep 27, 2017 in Object Oriented Programming rishu_darkshadow 311 views
1 vote
1 answer
2
2.3k views
Which of the following is not correct for virtual function in C++? 1) Must be declared in public section of class. 2) Virtual function can be static. 3) Virtual function should be accessed using pointers. 4) Virtual function is defined in base class.
asked Nov 9, 2017 in Others Devwritt 2.3k views
0 votes
1 answer
3
1.3k views
A member function can always access the data in________, (in C++). 1) the class of which it is member 2) the object of which it is a member 3) the public part of its class 4) the private part of its class
asked Nov 9, 2017 in Others Devwritt 1.3k views
0 votes
1 answer
4
380 views
the associativity of which of the following operators is Left to Right, in C++? 1) Unary Operator 2) Logical not 3) Array element access 4) addressof
asked Nov 9, 2017 in Others Devwritt 380 views
...