Answer the question
In order to leave comments, you need to log in
Design magic?
struct WorkExample
{
WorkExample (const int &number ){}
};
WorkExample wOne(1); // ok
WorkExample wTwo=1; // ok
struct Example
{
Example ( const std::string &line ){}
};
Example one("line"); // ok
Example two="line"; // error
const std::string &line
with const char *const line
, everything works.
Answer the question
In order to leave comments, you need to log in
The compiler does not do more than one conversion
If we replace with Example two=std::string("line");
, then everything will work
Example two="line"; -> Example two("line"); //Нет конструктора, который принимает const char*
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question