Hello :D
I've been learning C++ and I use SFML for a more engaging learning experience than just outputting text to the console. unfortunately, at times, my use of SFML extends past my knowledge of C++. Normally I just go back to reading a couple books that I have or I search the internet until i have a better understanding of C++ but this last problem I've ran into has me stumped because I don't really know what to search. I'm hoping someone out there can give me some specific terminology about this piece of code so I know what to google/what chapter I should be reading out of.
the problem started when i began passing "noncopyable" objects into functions, so I began researching the error I was getting and came across many pieces of code similar to the following.
changeWindow(sf::RenderWindow &window) : mainWindow(&window)
{
mainWindow -> window;
}
I have a basic understanding of passing objects by reference and using pointers but what I really don't understand is, what the heck is that colon and the "->" doing or what it's called?
In short, can someone please give me some direction for research so I can understand the above code?
changeWindow(sf::RenderWindow &window) : mainWindow(&window)
{
mainWindow -> window;
}
I have a basic understanding of passing objects by reference and using pointers but what I really don't understand is, what the heck is that colon and the "->" doing or what it's called?
In short
mainWindow -> window;
//is equivalent to
(*mainWindow).window
To explain it in simple words the -> access what is pointed by a pointer. Search pointer on the net for clear detail (Or check official C++ website). Also, the colon is related to constructor and is a common way to initialize attributes. So search "C++ constructor" on the net...