Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- class Bar
- {
- public:
- // Conster & Dester
- Bar() { printf("Bar %x is constructed\n", this); }
- ~Bar() { printf("Bar %x is destructed\n", this); }
- //Copier
- Bar(const Bar& bar)
- {
- printf("Bar is copied (copy constructor is called): "
- "%x -> %x\n", &bar, this);
- }
- const Bar& operator=(const Bar& rhs)
- {
- printf("Bar is assigned (operator= is called)\n");
- return rhs;
- }
- };
- Bar makeBar_val()
- {
- printf("makeBar_val called\n");
- return Bar();
- }
- int main()
- {
- printf("Before makeBar_val is called\n");
- Bar bar(makeBar_val());
- printf("After makeBar_val is called, got %x\n", &bar);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement