Copy constructor: is this a bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Program code:

#include <iostream>

struct Test {
        unsigned count;
        Test(): count() {
        }
        Test(const Test &x): count(x.count+1) {
        }
};

int main() {
        Test obj0, obj1=Test(), obj2=Test(Test());
        std::cout << obj0.count << '\n';
        std::cout << obj1.count << '\n';
        std::cout << obj2.count << '\n';
        return 0;
}

Expected result:

0
1
2

Actual result:

0
0
0

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux