My class structure is as follows:
Test_Camera.h:
class Test_Camera : public Camera_Interface { public: Test_Camera (string const& aName); ... Test_Camera.cpp
Test_Camera::Test_Camera(string const& aName) : Camera_Interface(0, 0, 0, 0), name(aName) In my code that instantiates a Test_Camera object I have 2 scenarios. The first compiles fine, but the second doesn't and I can't figure out why.
Test_Camera cam ("cam"); // This compiles Test_Camera& cam ("cam"); // This does not compile When I try to compile the second example I get an error:
error: invalid initialization of non-const reference to type 'Test_Camera&' from a temporary of type 'const char*'
I also tried:
string name = "cam"; Test_Camera& cam (name); //does not compile