Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::String  (Read 1271 times)

0 Members and 1 Guest are viewing this topic.

Elarys

  • Newbie
  • *
  • Posts: 5
    • View Profile
sf::String
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: sf::String
« Reply #1 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Elarys

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: sf::String
« Reply #2 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.
« Last Edit: August 03, 2012, 01:00:26 pm by Elarys »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::String
« Reply #3 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.
Laurent Gomila - SFML developer

 

anything