fork(5) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. template <class T1>
  6. class TypeSize {
  7. public:
  8. TypeSize(T1 value) {
  9. this->value = value;
  10. }
  11. void DataTypeSize() {
  12. cout << "value size is " << sizeof(T1) << endl;
  13. }
  14. private:
  15. T1 value;
  16. };
  17.  
  18. template <class T1>
  19. class TypeInfo : public TypeSize<T1> {
  20. public:
  21. TypeInfo(T1 value) : TypeSize<T1>(value) { //<<<<<<< Ошибка!
  22.  
  23. }
  24. };
  25.  
  26.  
  27. int main() {
  28.  
  29. int a = 2;
  30. TypeInfo<int> c(a);
  31. c.DataTypeSize();
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 4408KB
stdin
Standard input is empty
stdout
value size is 4