[ create a new paste ] login | about

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

C++, pasted on Nov 29:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Base
{
public:
    Base(){}
    virtual ~Base(){}
private:
    Base(const Base &other) ;   // Only declaration! No definition.
    Base &operator=(const Base &other);
} ;

int main(int argc, char* argv[])
{
    const Base b ;          // ok
    const Base *pb = &Base() ;      // ok
    const Base &qb = Base() ;       // Illegal, why?

    return 0;
}


Output:
1
2
3
4
5
cc1plus: warnings being treated as errors
In function 'int main(int, char**)':
Line 14: warning: taking address of temporary
Line 7: error: 'Base::Base(const Base&)' is private
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: