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

Author Topic: Super basic C++ question  (Read 927 times)

0 Members and 1 Guest are viewing this topic.

IOInterrupt

  • Newbie
  • *
  • Posts: 2
    • View Profile
Super basic C++ question
« on: March 10, 2013, 08:54:05 pm »
Hello, I am new to C++ and needless to say, SFML.  I have a really basic question regarding the object initialization.  While I have no experience with C++, I have been developing with PHP for 7+ years so I do have a understanding of programming fundamentals. 

As an example:
    sf::VideoMode videoMode(320,240);
    sf::Window window(videoMode,"Basic Display Window");

Are these statements initializing the variables and then immediately running the constructor method with the given parameters?  It just looks a little foreign to me and I would expect something more similar to.

sf::VideoMode viewMode = new sf::VideoMode(320,240);
sf::Window window = new sf:Window(videoMode,"Basic Display Window");

Any articles that you might be able to link to as well would be greatly appreciated.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Super basic C++ question
« Reply #1 on: March 10, 2013, 08:59:26 pm »
I don't think that learning C++ on the SFML forum is the best idea ever... ;)

Why don't you buy a good book, or at least read a good online reference about the language?
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11008
    • View Profile
    • development blog
    • Email
Re: Super basic C++ question
« Reply #2 on: March 10, 2013, 09:00:13 pm »
Yes the first example is indeed C++ the second is more like Java or PHP.

C++ is not a language you can just learn by working a bit with it, but it's quite complex and reading a book is mandatory, but please make it a good book, so you don't learn unnecessary ways of doing things.

Also for general C++ questions Google might give you a much faster and mostly better answer. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

IOInterrupt

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Super basic C++ question
« Reply #3 on: March 10, 2013, 09:14:32 pm »
Thanks guys.  I read a good chunk of 'Thinking in C++' quite a while back, but I guess I will need to dig into it again, because I don't recall objects being initialized like that....I thought maybe I was seeing as shorthand version or something.

 

anything