• Home
  • Interview Questions
  • Online Quiz Tests
  • Blog
  • Contact Us

Global Guideline - Interviewer and Interviewee Guide.

Links
  • Home
  • Interview Questions
  • Online Quiz Tests
  • Blog
  • Contact Us
  1. Interviews
  2. C++ Language
  3. C++ Template

C++ Template Question:

What is the validity of template parameters?
a) inside that block only
b) inside the class
c) whole program
d) any of the mentioned

C++ Template Interview Question
C++ Template Interview Question

Answer:

a) inside that block only


Previous QuestionNext Question
Which keyword can be used in template?
a) class
b) typename
c) both a & b
d) function
What is the output of this program?

#include <iostream>
using namespace std;
template <class T, int N>
class mysequence
{
T memblock [N];
public:
void setmember (int x, T value);
T getmember (int x);
};
template <class T, int N>
void mysequence<T,N> :: setmember (int x, T value)
{
memblock[x] = value;
}
template <class T, int N>
T mysequence<T,N> :: getmember (int x)
{
return memblock[x];
}
int main ()
{
mysequence <int, 5> myints;
mysequence <double, 5> myfloats;
myints.setmember (0, 100);
myfloats.setmember (3, 3.1416);
cout << myints.getmember(0) << 'n';
cout << myfloats.getmember(3) << 'n';
return 0;
}
a) 100
b) 3.1416
c) 100
3.1416
d) none of the mentioned

Interview Categories:

    • Basic C++ Syntax
    • C++ Access Control
    • C++ COM ActiveX
    • C++ Constructors
    • C++ Containers
    • C++ Exception Handling
    • C++ Friend
    • C++ Inheritance
    • C++ Inline Function
    • C++ New And Delete
    • C++ Operator Overloading
    • C++ Pointers and Functions
    • C++ Programmer
    • C++ References
    • C++ Static Data
    • C++ Template
    • C++ Type Checking
    • C++ Virtual Functions

Most Popular Quiz Categories:

Java AWT And SwingHTMLSQLSAT (Scholastic Aptitude Test) Sentence CorrectionBiology Aptitude TestStatistics Aptitude TestNetworkingChemistry Aptitude TestOOAD (Object Oriented Analysis and Design)Management

Most Popular Interviews

  • Business and Economy
  • Networking
  • Computer Programming
  • Operating System
  • Computer Hardware

Most Popular Quizzes

  • Information Technology
  • Networking
  • Engineering
  • Java
  • Accounting

Keep in touch with us

 

Copyright © 2007 - 2025 globalguideline.com

all rights reserved.
  • About Us
  • Contact Us
  • Blog
  • Terms of use
  • Privacy Policy