Quizzes
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
struct
:
Content language: Русский
English
Чему будет равно значение А<9>::vаluе+А<2,2>::vаluе, если структура А определена следующим образом: tеmplаtе<unsignеd N, unsignеd I=0> struсt А : А<N/2,I+1>{}; tеmрlаtе<unsignеd I> struсt А<0,I>{ stаtiс соnst unsignеd vаluе = I; };
struct
Скомпилируется ли следующий код? template <class T=void> // 1 struct A { int a; }; template <> struct A<int> { char c; // 2 }; void Test() { A<>().a; // 3 A<int>().c; // 4 }
struct
Скомпилируется ли код? 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 }
struct
Какой тип будет иметь 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*> { };
struct
Что будет выведено на экран в результате выполнения программы: #include <iostream> typedef int*** INT; template <typename T> struct S { enum {result = 2}; }; template<typename T> struct S<T*> { enum {result = 1 + S<T>::result}; }; int main() { std::cout << S<INT>::result; return 0; }
struct
Какой тип будет иметь В<соnst int*>::tуpе при следующем определении класса В: tеmрlаtе<сlаss Т> struсt А{ tуреdеf Т* tуpе; }; tеmрlаtе<сlаss Т> struсt В{ tуpеdеf tуpеnаmе А<tуpеnаmе А<Т>::tуpе>::tуpе tуpе; };
struct
Что будет в результате выполнения кода? #include <iostream> using namespace std; template<class T> struct Bar { T data; Bar(){ cout << "Default construct"<<endl; } template<class X> Bar(const Bar<X>& val) { data = val.data; cout << "Template copy construct"; } }; int main(){ Bar<int> b1; Bar<int> b2(b1); Bar<double> b3(b1); cin.get(); return 0; }
struct
Что будет выведено на экран? #include <iostream> #include <string> template<int T> std::string StrangeFunc() { return StrangeFuncStruct<T>::value(); } template<int T, bool lt16 = (T<16)> struct StrangeFuncStruct { static std::string value() { return StrangeFuncStruct<T, (T<16)>::value(); } }; template<int T> struct StrangeFuncStruct<T, true> { static std::string value() { return std::string(1, T + ((T>9)?'A'-10:'0')); } }; template<int T> struct StrangeFuncStruct<T, false> { static std::string value() { return StrangeFuncStruct<(T/16)>::value() + StrangeFuncStruct<(T%16)>::value(); } }; int main() { std::cout << StrangeFunc<137+137*256>() << std::endl; }
struct
Какие из объявлений шаблонов верны?
struct
Что будет выведено в результате выполнения кода: #include <iostream> struct A { struct B { int value; } b; }; template<typename T> void func(typename T::B b) { std::cout << b.value; } int main(int argc, char * argv[]) { A a = {{5}}; func(a.b); }
struct
← Prev
3
4
5
6
7
Next →
Sign Up Now
or
Subscribe for future quizzes