Let's say I have a header file with a class that uses std::string.
std::string
#include <string> class Foo { std::string Bar; public: // ... }
The user of this header file may not want to std::stringbe included in his / her project. So, how to limit the inclusion of only the title?
The user of your class must include it <string>, otherwise their compiler will not know how large the object is Foo(and if constructors / destructors are Foodefined in the string, then the compiler will also not know what constructor / destructor to call the element string).
<string>
Foo
string
++ ( C). , , , PIMPL.
, . , , .
, pimpl idiom.
, , Foo , <string> ? std (, , <string> C, , C ++ Standard Library).
std
, , ++. , , "std::string", , , . .h.
, , - "using":
//This is how users can use an adt with same name but in different namespaces using std::string; string bar = "there"; using my_own_lib::string; string bar1 = "here";
You cannot do this. If the user does not want to include std::string, then he or she should not use this class at all. std::stringmust be included in the project to properly link your class.
Source: https://habr.com/ru/post/1654937/More articles:Flask-CORS does not work for POST, but works for GET - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1654933/is-x-amz-expires-a-required-headerparameter-for-requests-to-aws&usg=ALkJrhiuEIFfCtky6U1mV2GLLlV5Z0bmgwHow to get a declaration for DebugBreak without turning on Windows.h? - c ++Сложение текста в NSTextView/UITextView с использованием текстового набора - iossql count / sum the number of calls up to a certain date in another column - sqlHow to implement tag input control using hint code in JSX? - reactjshow to get an error key in an array of laravel error messages - arraysELM parse nested json - jsonUNNotificationContentExtension not showing - iosParticle emitter does not appear above image (quick spritekit) - swiftAll Articles