This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Base | |
{ | |
public: | |
virtual void action() { std::cout << "Base::action()\n"; } | |
}; | |
class Derived : public Base | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() | |
{ | |
int cond = 1; | |
if (int var = cond) | |
{ | |
std::cout << "if: var=" << var << "\n"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <typeinfo> | |
#define PRINT_EXPR(T) do { std::cout << "parameter: " << #T << "\t\t\t\ttype: " << typeid(T).name() << std::endl; } while(false); | |
#define PRINT_TYPE(T) do { T val; std::cout << "parameter: " << #T << "\t\t\t\ttype: " << typeid(val).name() << std::endl; } while(false); | |
template <typename T> | |
void print(T t) | |
{ | |
std::cout << "type: " << typeid(T).name() << " value: " << t << std::endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include <typeinfo> | |
template <typename T> | |
void f(T t) | |
{ | |
std::cout << typeid(t).name() << ":" << t << std::endl; | |
} |
NewerOlder