using namespace std;
template <class T1>
class TypeSize
{
public:
TypeSize(T1 value);
void DataTypeSize();
protected:
T1 value;
};
using namespace std;
template <class T1>
class TypeInfo : public TypeSize<T1> // Здесь получаю C2143 синтаксическая ошибка: отсутствие "," перед "<"
{
public:
TypeInfo(T1 value);
void ShowTypeName();
};
#pragma once
#include "targetver.h"
#include <tchar.h>
#include <iostream>
#include "TypeInfo.h"
#include "TypeSize.h"
#pragma once
#include <iostream>
template<typename T>
class TypeSize
{
public:
TypeSize(T v) : value{ v } {};
~TypeSize() {};
void dataTypeSize();
protected:
T value;
};
template<typename T>
void TypeSize<T>::dataTypeSize()
{
std::cout << "size: " << sizeof(value) << std::endl;
}
#pragma once
#include <typeinfo> // std::typeid()
#include "TypeSize.h"
template<typename T>
class TypeInfo : public TypeSize<T>
{
public:
TypeInfo(T v) : TypeSize<T>(v) {};
~TypeInfo() {};
void showTypeInfo();
};
template<typename T>
void TypeInfo<T>::showTypeInfo()
{
std::cout << "type: " << typeid(this->value).name() << std::endl;
}
#include "TypeInfo.h"
int main()
{
int a{ 5 };
TypeInfo<int> infInt(a);
infInt.dataTypeSize();
infInt.showTypeInfo();
std::getchar();
}