• Forum
  • Lounge
  • Best way to write function prototypes in

 
Best way to write function prototypes in text

While writing tutorials, it's often necessary to refer to class member functions. Taking into account how easy it is for a beginner as well as correctness, which form do you think I should use to refer to a function:
-> sf::Window::PollEvent()
-> sf::Window::PollEvent(sf::Event&)
-> Window.PollEvent [where Window is a variable of type sf::Window]
-> Window.PollEvent(Event) [where Window is a variable of type sf::Window and Event is a variable of type sf::Event]

Thanks
-Xander314/Zephyr/SFMLCoder
Last edited on
E. None of the above. If you're referring to a function, you don't need to show all its parameters, but you should also make clear that it is a function and not a variable. Thus, I prefer this:
sf::Window::PollEvent()
It's clear that this is a function, and the parameters can be/already have been discussed.
Yeah. I was posting some stuff on the SFML forums, and it suddenly occurred to me that it looked like a variable or type without the brackets. Thanks :)

EDIT: And do you think that notation is likely to confuse beginning programmers? (And don't say that they should know that before using SFML, because I want my audience to be as wide as possible :p)
Last edited on
I think they should at least know how to create variables and functions before they try to use SFML...
closed account (3hM2Nwbp)
ยข2 - Provide a hyperlink to the appropriate Doxygen-generated page?
* Oh - this isn't code that you wrote, I misunderstood.

I'd go with: sf::Window::PollEvent(sf::Event&)
Because:

A) They won't be as tempted to copy & paste it into their program.
B) It's less ambiguous than an empty parameter list.
C) Repetition is the key to memorizing - hammer the methods into their heads.
Last edited on
@firedraco I agree - I just thought they might be confused by seeing a member function referred to as though it were static, but meh, they should probably understand that already too.

@Luc In fact I can link to the doxygen documentation, because it's almost always an SFML function. I might start doing that, and I'll have it open in a new window...
Topic archived. No new replies allowed.