I have 2 objects that use std::string in order to work. Object A may be used independently from object B. However, a situation might arise where both object A and B might be used in the same main.cpp file which might cause header collision and the header might get compiled twice. How do I prevent from being compiled twice? I've tried using:
#ifndef string_H
#define string_H
#endif
It does not work and object B is unable to use the string library, I think this is meant to be used only for third-party libraries such as my own and not for official libraries. So my question is, how would you put include guards over a header from a standard library?
EDIT: I am using Visual Studio 2017 so I believe it's all written by Microsoft. Thank you for your answers, I was not aware that std:: has include guards already built-in.