Skip to main content
11 events
when toggle format what by license comment
Oct 4, 2023 at 4:36 history edited Greenonline CC BY-SA 4.0
Fixed typo
S Oct 3, 2023 at 10:06 history suggested kpprabhash CC BY-SA 4.0
foo.something(); should be changed to myFoo.something();
Sep 28, 2023 at 4:32 review Suggested edits
S Oct 3, 2023 at 10:06
May 9, 2016 at 19:58 comment added jfpoilpret I think it would be worth mentioning the important difference between a pointer and a reference: a pointer can be NULL (i.e. 0 meaning that it points to nothing) whereas a reference shall always refer to a real variable (although technically it is possible to trick the compiler but nobody would do that). Personally I always prefer using references if I don't want to allow NULL.
May 9, 2016 at 18:34 comment added Majenko It depends how you are going to use the class. If you want to use it in other places it can be worth turning it into a library - have a .h file with the class declaration in it, and a .cpp file with the actual class methods. If you don't want to split it into separate declaration and definition then you should keep it in your sketch. It can still be useful to split it even then though if you have multiple source files in your sketch that all want to use it.
May 9, 2016 at 18:32 comment added dinotom @Majenko...Thank you, one other item. Put the class in the projects header file?
May 9, 2016 at 18:31 vote accept dinotom
May 9, 2016 at 18:17 history edited Majenko CC BY-SA 3.0
added 967 characters in body
May 9, 2016 at 18:05 comment added Majenko Looks fine to me. Although I tend to pass an object to the constructor and store it as a pointer in the class I am making, then access the object through that pointer - means you don't have to then keep passing the same object over and over again.
May 9, 2016 at 18:00 comment added dinotom So what I have done is correct, although not necessarily the best method. My thought with the pointer, was since that player can be called dozens of times, I want it to call the same object every time. Is my code written properly for that intent?
May 9, 2016 at 17:50 history answered Majenko CC BY-SA 3.0