Euronet interview questions
Some questions were from test4geeks void GetSomeVariable(int **i) { if(*i == NULL) { *i = new int; } **i = 20; } int main() { int someValue = 10; GetSomeVariable(&someValue); cout << someValue <<endl; int *ptr = nullptr; GetSomeVariable(&ptr); cout << *ptr <<endl; } How to make the code compilable without changing GetSomeVariable? Solution: Use Function overloading or Type traits #include <iostream> #include <type_traits> void g(int*) { std::cout << 'L'; } void g(int**) { std::cout << 'R'; } template<typename T> void f(T t) { if (std::is_same_v<T, int>) { std::cout << 1; } if (std::is_same_v<T, int*>) { std::cout << 2; } if (std::is_same_v<T, int**>) { std::cout <...