SFML community forums

Help => Graphics => Topic started by: Elarys on August 03, 2012, 01:27:46 am

Title: sf::String
Post by: Elarys on August 03, 2012, 01:27:46 am
I'm trying to do some error handling, and also playing around with SFML while learning C++, so I might be missing something here. But why am I not allowed to just string 2 sf::String strings together with << like I can with cout.

For example, this fails to compile at <<

        sf::String hdr, msg;
        sf::Font myFont;
        sf::Text myText;
        sf::String fontFamily = "kaiu.ttf";

        if (!myFont.loadFromFile(fontFamily))
        {
                hdr = "Warning, unable to load font";
                msg = "Unable to load font " << fontFamily;
        }

Thanks
Title: Re: sf::String
Post by: eXpl0it3r on August 03, 2012, 02:06:51 am
Because it's not implemented that way... :-\

You should really rather take a good C++ book and read it front to back than trying to do things with SFML without knowing what you're actually doing on the syntax and sematics level.

If you want an overview what sf::String can do, then take a look at the documentation (http://www.sfml-dev.org/documentation/2.0/classsf_1_1String.php).
Title: Re: sf::String
Post by: Elarys on August 03, 2012, 12:09:19 pm
You're probably right, I jumped ahead too fast in efforts to keep up motivation and 'fun'.

Back to C++ Primer it is. Sorry

Edit: Turns out I had a case of Visual Studio Intellisense failure. When using +, it was highlighting the + with red underlines to suggest an error. So I assumed I was being an noob, and so I then tried << as per my original post. Which then wouldn't compile.
Title: Re: sf::String
Post by: Laurent on August 04, 2012, 11:19:28 am
Never trust Intellisense. It can be a helper and provide shortcuts, but never use it as a doc reference.