I would like to implement a table that will consist of some names of data types so that I will be able use them in loop to cout
my function. How to do it? I have already tried with the table that is in my code but it doesn't work. Probably it's something with pointers.
#include <iostream>
#include <limits>
#include <iomanip>
using namespace std;
template<typename T>
void sizeF(string opis) {
int x = sizeof(T);
if (x==1)
cout << "Rozmiar typu "+opis+" to " << x << " bajt.\n";
else if (x==2 || x==4)
cout << "Rozmiar typu "+opis+" to " << x << " bajty.\n";
else
cout << "Rozmiar typu "+opis+" to " << x << " bajtów.\n";
}
template<typename T>
void maxMinF(string opis)
{
cout << opis << ": minimalna wartosc: " << numeric_limits<T>::min() << ", maksymalna wartosc: " << numeric_limits<T>::max() << endl;
}
int main()
{
char tab[1][15] = {"short int"};
sizeF<tab[0]>(tab[0]);
sizeF<int>("int");
sizeF<unsigned long long>("unsigned long long");
sizeF<bool>("bool");
sizeF<char>("char");
sizeF<double>("double");
sizeF<long double>("long double");
sizeF<long long>("long long");
sizeF<short>("short");
sizeF<unsigned short>("usigned short");
cout << endl;
maxMinF<short int>("short int");
maxMinF<int>("int");
maxMinF<unsigned long long>("unsigned long long");
maxMinF<bool>("bool");
maxMinF<char>("char");
maxMinF<double>("double");
maxMinF<long double>("long double");
maxMinF<long long>("long long");
maxMinF<short>("short");
maxMinF<unsigned short>("usigned short");
return 0;
}