On previous lecture we learnt, that the & can be used to force the system to pass on values from the same named variable (argument) to the function’s variable (parameters). void greet(string& names);
That does not seem to work if we put the definition on the greet.cpp file nor if put on the header file. Does this mean it cannot be used in linked files at all? And does this now cause three names to be existing at the same time thus tripling the amount of data stored on name(s)?
Could you be more specific about what did not work? Writing exact contents of the involved files and any errors you are getting for any command you run is helpful.
I get the errors LNK1120 and LNK2019. Without the & no errors and it compiles fine. I am on Visual Studio 2022 Common
If I put the & on both, I get an error “C2644, void greet(std::string &) cannot convert argument 1 from const char to std::string &”
I do not have char type anywhere… but I think it is thinking & is the char in question, it does not say the entire argument: (std::string& name) it just says sdt::string &, which resulted me thinking & is incompatible with the separate files.