Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- template<typename T1, typename T2>
- class DataType
- {
- public:
- DataType(T1 value1, T2 value2)
- {
- this->value1 = value1;
- this->value2 = value2;
- }
- void DataTypeSize()
- {
- std::cout << "Значение " << value1 << " занимает " << sizeof(value1) << " байта" << std::endl;
- std::cout << "Значение " << value2 << " занимает " << sizeof(value2) << " байта" << std::endl;
- }
- protected:
- T1 value1;
- T2 value2;
- };
- template<typename PT1, typename PT2>
- class TypeInfo : public DataType<PT1, PT2>
- {
- public:
- TypeInfo(PT1 Pvalue1, PT2 Pvalue2) : DataType<PT1, PT2>(Pvalue1, Pvalue2)
- {
- }
- void ShowTypeName()
- {
- std::cout << "Тип данных значения " << this->value1 << " - " << typeid(this->value1).name() << std::endl;
- std::cout << "Тип данных значения " << this->value2 << " - " << (typeid(this->value2).name()) << std::endl;
- }
- };
- int main(int argc, char *argv[])
- {
- setlocale(LC_ALL, "Rus");
- srand(time(NULL));
- TypeInfo<int, std::string> dt(5.99, "пять");
- dt.DataTypeSize();
- std::cout << "\n\n";
- dt.ShowTypeName();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement