I’m getting
error LNK2005: "bool __cdecl hasLogin(void)" (?hasLogin@@YA_NXZ) already defined in B.obj
error. func is declared in B.cpp file, and it’s called from A.cpp file. B.cpp is included in A.cpp. Google says that it’s not good to include cpp in antother cpp. If I copy/paste func in A.cpp there’s no problem. How to solve tsis problem correctly?
PS I’m new to c++, so forgive if the question is dump.
You should generally declare your classes/functions in .h (header) files, and implement them in .cpp files. It’s also usually a good idea to put include guards in your .h files so including them multiple times is not a problem. That way your .cpp files can include any .h file without causing any conflicts.
An example; test.h
and the corresponding .cpp file