Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » From std::string to String
Re: From std::string to String [message #49470 is a reply to message #49468] Thu, 15 February 2018 16:03 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Hello Giorgio

[It seems Omari has already replied. Smile ]

Quote:

I use LoadFile() and noticed that is has no .close() method or something like that (it replaces a ifstream in c++ standard library and with it I have to open and close the file): my understanding is that I have not to open/close the stream as with ifstream; is my understanding correct?


No, you don't. LoadFile() is a function, it does not have any method. It reads a file into a string, and closes the file/stream automatically.
If you need control over the stream, you can use FileIn, FileOut, FileAppend classes. (In fact, LoadFile() function uses an instance of FileIn)
They'll be closed automatically when they get out of their scope (when they are destroyed). In between you can explicity call Close() if you need to.


Previously, I used std::vector<std::string> and the application compiled, but now I get "error C2280: attempting to reference a deleted function".


Probably because of move/copy semantics. Something is destroyed in the process, before it can be referenced. chech if your data can be copied or moved.
As far as I can see, you are passing a copy of vector, just put an ampersand (&)

Best regards,
Oblivion


[Updated on: Thu, 15 February 2018 16:06]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Filtering CR from an EditString
Next Topic: MSSQL and codepage
Goto Forum:
  


Current Time: Wed May 08 04:45:20 CEST 2024

Total time taken to generate the page: 0.03301 seconds