[ create a new paste ] login | about

Link: http://codepad.org/ygk2FJbY    [ raw code | output | fork ]

C++, pasted on Feb 16:
#include <iostream>
#define DEBUG Debug(__FUNCTION__, __LINE__)

class Debug {
public:
    Debug (const char* f, int line) { std::cout << f << " (" << line << ")> "; }
    ~Debug () { std::cout << std::endl; }
    template <typename T> void operator << (const T& t) { std::cout << t; }
};

class B {

};

class C {

};

class A {
public:
  A (const B& b) { DEBUG; }
  A (const A& a) { DEBUG; }
  void operator= (const C& c) { DEBUG; }
};

int main () {
  DEBUG << "create b";        B b;
  DEBUG << "create c";        C c;
  DEBUG << "create a from b"; A a = b;
  DEBUG << "copy b to a";     a = b;
  DEBUG << "copy c to a";     a = c;
}


Output:
1
2
3
4
5
6
7
8
9
main (28)> create b
main (29)> create c
main (30)> create a from b
A (22)> 
A (23)> 
main (31)> copy b to a
A (22)> 
main (32)> copy c to a
operator= (24)> 


Create a new paste based on this one


Comments: