0
How I can write one or more objects that contain a string in a same file?
I tried to write a object like: #include <iostream> #include <string> using namespace std; class object { private: string something; long int anything; public: object (string likethis, long int bored){ this -> something = likethis; this -> anything = bored; } }; and tried to write 5 object of this class in a file, but don't load all of the attrbutes. I tried without a string, and works. And I tried to with a string like this: char myString[20], and works. So, how I can do this with a
2 ответов
0
If you don't use 'using namespace std;' you need std:: before each 'string' (std::string).
0
Oh, missed this the first time, you should make the constructor public.