24 lines
489 B
C++
24 lines
489 B
C++
#include "iostream"
|
|
#include "string"
|
|
|
|
template <typename T>
|
|
T f(T x) {
|
|
return x * x;
|
|
}
|
|
|
|
template <typename X>
|
|
void input(std::string message, X &target) {
|
|
std::cout << message;
|
|
std::cin >> target;
|
|
}
|
|
|
|
int main() {
|
|
std::string lang = "C";
|
|
std::string version = "++";
|
|
lang = lang + version;
|
|
std::cout << "Hello World, said by " << lang << "!" << std::endl;
|
|
int x = 0;
|
|
input("x = ", x);
|
|
std::cout << "f(x) = " << f<int>(x) << std::endl;
|
|
return 0;
|
|
} |