C
Christian Meier
Hi NG
I'm using "lint" and got a message which I do not understand.
When I "lint" the following code I get the message "Initializing a non-const
reference C &' with a non-lvalue".
class C {
public:
static C GetTemporaryInstance() { return C(); }
C& operator<<(int) { return *this; }
private:
C() {}
};
int main()
{
C::GetTemporaryInstance() << 5;
}
1. Can you explain me the lint message? Where am I initializing a C
reference?
2. Is this code legal c++ or is it not allowed to call the operator<< of a
temporary object like the return value of C::GetTemporaryInstance()?
Thanks for your answers and regards,
Chris
I'm using "lint" and got a message which I do not understand.
When I "lint" the following code I get the message "Initializing a non-const
reference C &' with a non-lvalue".
class C {
public:
static C GetTemporaryInstance() { return C(); }
C& operator<<(int) { return *this; }
private:
C() {}
};
int main()
{
C::GetTemporaryInstance() << 5;
}
1. Can you explain me the lint message? Where am I initializing a C
reference?
2. Is this code legal c++ or is it not allowed to call the operator<< of a
temporary object like the return value of C::GetTemporaryInstance()?
Thanks for your answers and regards,
Chris