C++
Select the ...
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
Select the correct statements:
You can explicitly specify template parameters in angle brackets
For functions, default template parameters can be set using the = sign after declaring a template parameter
The template parameters specified explicitly must match the types of parameters passed to the function
Template functions can be overloaded
Explanation
Default template options are allowed only for classes and structures. If the template parameter is specified explicitly, the compiler will try to cast the passed parameters to the required types.
data-type-conversion
struct
class
template
Like
Login in
to like
Comment
Login in
to comment
Share
Tweet
Related Content
Что будет выведено в результате выполнения данной программы: template<class T, class U> struct A{ struct dummy{char _[2];}; static char _(T); static dummy _(...); static const bool value=sizeof(_(U()))==sizeof(char); }; struct B{}; struct C:B{}; ... cout << A<B,C>::value << A<B,B>::value << A<C,B>::value;
Скомпилируется ли следующий код? template <class T> struct A { template <class K> A(K a) { } };
Что выведет на экран данный код? #include <iostream> template <class T> struct A { typedef typename T::C TC; A(){ TC::out(); } }; struct B: A<B> { struct C { void out(){ std::cout<<"C";} }; }; int main() { B b; return 0; }
Скомпилируется ли код? template<typename T> class A{ A(){} }; // 1 template<typename T> struct B{ B(){} }; // 2 template<typename T> union C{ C(){} }; // 3 template<template<typename> class U, typename V> struct D { D() { U<V> u; } }; int main() { D<A, int> a; // 4 D<B, int> b; // 5 D<C, int> c; // 6 }
Какой тип будет иметь s2<int>::type, если s2 определена следующим образом: tеmplаtе<сlаss T> struсt s { tуpеdеf T* tуpе; }; tеmplаtе<сlаss T> struсt s<T&> { typеdеf соnst T* tуpе; }; tеmрlаtе<сlаss T> struсt s2 : s<T*> { };
C
++
Quiz
Login to learn C++
or
Read more about
C++ Quizzes
Follow CodeGalaxy
Mobile Beta
Send Feedback
Keep exploring
C++ quizzes
int main() { const int* i = int(); // 1 int const* j = int(); //2 int* const k = int(); //3 int* l(); //4 ++i; //5 ++j; //6 ++k; //7 ++*k; //8 ++l; //9 } Откомпилируется ли такой код? Если нет, то в каких строчках будут ошибки компиляции? После стандарта C++14.
Какой результат работы программы? #include <iostream> using namespace std; void f(double) { cout<<"f1"<<endl; } void f(const int ) { cout<<"f2"<<endl; } void f( int & ) { cout<<"f3"<<endl; } void main(void) { int n = 1; double b = 2; f(n); f(b); }
#include <iostream> using namespace std; int &test() { static int a = 3; return a; } int main() { ++++++test(); cout << test() << endl; return 0; } Что выведет cout?
При истинности какого из приведенных высказываний имеет смысл вычитание указателей?
Какое ключевое слово используется для описания пространства имен?
В чем разница между X x; и X x(); ?
Sign Up Now
or
Subscribe for future quizzes
Login in to like
Login in to comment