T
tthunder
Hi @all,
My small example does not compile... I know, that this (as always) has
reasons, but I want to know WHY?
BTW:
I only get errors with g++ (4.x), BCB (6.0),...
VS C++ (2005) works perfectly (without warnings etc.)
class classValue
{
public:
classValue() {}
};
class classHolder
{
public: classHolder(classValue &ami) {} // <== I know, but in
this case reference MUST be non-const
};
classHolder getAHolder()
{
return classValue(); // <--- Error: conversion from
'classValue' to non-scalar type 'classHolder' requested
}
Using a little trick, everthing works well...
class classValue
{
public:
classValue() {}
classValue &self() { return *this; }
};
class classHolder
{
public: classHolder(classValue &ami) {}
};
classHolder getAHolder()
{ return classValue().self();}
But why must I use this nasty indirection?
How is this phenomenon called?
Any other suggestions?
THX,
Kirsten
My small example does not compile... I know, that this (as always) has
reasons, but I want to know WHY?
BTW:
I only get errors with g++ (4.x), BCB (6.0),...
VS C++ (2005) works perfectly (without warnings etc.)
class classValue
{
public:
classValue() {}
};
class classHolder
{
public: classHolder(classValue &ami) {} // <== I know, but in
this case reference MUST be non-const
};
classHolder getAHolder()
{
return classValue(); // <--- Error: conversion from
'classValue' to non-scalar type 'classHolder' requested
}
Using a little trick, everthing works well...
class classValue
{
public:
classValue() {}
classValue &self() { return *this; }
};
class classHolder
{
public: classHolder(classValue &ami) {}
};
classHolder getAHolder()
{ return classValue().self();}
But why must I use this nasty indirection?
How is this phenomenon called?
Any other suggestions?
THX,
Kirsten