Article ID: 147427
Article Last Modified on 12/9/2003
int temp() { return 1; }
class Test
{
public:
int member;
int& ref_member;
Test();
};
Test::Test() : ref_member( temp() )
{
}
When this error is encountered, the solution is to change the code so that
the reference member is not initialized to a temporary variable. The
reference must be initialized to an object that will exist for the lifetime
of the reference member.
Keywords: kbbug kbdocerr kbcpponly kbcompiler kboldocs KB147427