Passing temprary by reference requires copy constructor in 3.4?
Peter Cech
pcech@vision.ee.ethz.ch
Fri Nov 26 19:38:00 GMT 2004
Hi,
trying to compile
class EventObject
{
public:
EventObject() {}
private:
EventObject(const EventObject&);
};
class AnyEvent : public EventObject
{
public:
AnyEvent() {}
private:
AnyEvent(const AnyEvent&);
};
void invoke(const EventObject &) {}
void caller1()
{
AnyEvent event;
invoke(event);
}
void caller2()
{
invoke(AnyEvent());
}
leads to following error with both gcc (GCC) 3.4.3 (Gentoo Linux 3.4.3,
ssp-3.4.3-0, pie-8.7.6.6) and gcc (GCC) 4.0.0 20041121 (experimental)
a.cpp: In function `void caller2()':
a.cpp:16: error: `AnyEvent::AnyEvent(const AnyEvent&)' is private
a.cpp:29: error: within this context
Why gcc requires copy constructor in such situation?
Regards,
Peter Cech
More information about the Gcc
mailing list