fork download
class Foo
        Foo(const char* ){}
        friend void InitMethod(Foo& obj);
void InitMethod(Foo& obj){}
int main()
    Foo myVar("InitMe");
    InitMethod(myVar);    //Works

    InitMethod("InitMe"); //Does not work  
    return 0;
Compilation error #stdin compilation error #stdout 0s 0KB
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:13: error: invalid initialization of non-const reference of type ‘Foo&’ from a temporary of type ‘const char*’
prog.cpp:7: error: in passing argument 1 of ‘void InitMethod(Foo&)’

Standard output is empty