#include <iostream>
using namespace std;
template<typename T>
class Size {
public:
T width;
T height;
Size(T width, T height) {
this->width = width;
this->height = height;
}
string asText() {
char style[30];
snprintf(style, 30, "[%f; %f]",
(double)width, (double)height);
return style;
}
};
Size<int> sizeInt(5, 8);
string textInt = sizeInt.asText();
//textInt is "[5.000000; 8.000000]"
Size<float> sizeFloat(3.7, 1.58);
string textFloat = sizeFloat.asText();
//textFloat is "[3.700000; 1.580000]"
cout << "textInt is " << textInt << "\n";
cout << "textFloat is " << textFloat;