Why does C++ reject appending a structure to a binary file if it contains a member of the string class?

前端 未结 2 417
春和景丽
春和景丽 2021-01-27 07:51

So today I made almost no progress programming because I very slowly realized that C++ is a very type-cased sensitive language in the respect that I cannot append a structure to

2条回答
  •  梦谈多话
    2021-01-27 08:08

    std::string is a class that stores pointers to another memory location where the actual string is stored. If you write std::string to file, only the bytes representing the pointers is written, not the string itself.

提交回复
热议问题