Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- #define LOG(msg) log(__CLASS__, msg);
- void log(const char* cls, string str)
- {
- cout << "[" << cls << "] " << str << endl;
- }
- class MyClass1
- {
- public:
- void foo()
- {
- LOG("the message");
- }
- };
- class MyClass2
- {
- public:
- void foo()
- {
- LOG("another one message");
- }
- };
- int main()
- {
- MyClass1 obj1;
- MyClass2 obj2;
- obj1.foo(); // [MyClass1] the message
- obj2.foo(); // [MyClass2] another one message
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment