Skip to main content

Timeline for Not understanding C++ arrays

Current License: CC BY-SA 3.0

7 events
when toggle format what by license comment
Feb 12, 2017 at 17:01 comment added KIIV @GregoryR.Pace I can imagine that code without any variable just by using template class. It's perfect if you have one instance (or two). For more instances with different template parameters it might take more code space.
Feb 12, 2017 at 16:57 history edited KIIV CC BY-SA 3.0
Added example code without any variables
Feb 12, 2017 at 14:44 comment added Gregory R. Pace Concerning my last comment, I was missing the destructor in the .cpp file. I added it, and it compiled without errors.
Feb 12, 2017 at 14:38 comment added Gregory R. Pace Thanks again, KIIV. I somewhat understand. I moved the initialization to the header file where it was first declared, then got undefined reference for the destructor. I commented-out the destructor in the header file and it compiled without errors. Not real sure I like the destructor being commented-out, though.
Feb 12, 2017 at 13:59 comment added KIIV In the example there is declaration and initialization at once. In the class you have declaration in the class and initialization later. In the definition brackets means size (number of elements). Anywhere else it means accessing element at passed position (index)
Feb 12, 2017 at 13:51 comment added Gregory R. Pace Thank you, KIIV. However, this initialization is based on the original library for the device as well as an example at bildr.org/2011/02/cd74hc4067-arduino. There are 4 separate control pins the device needs to connect to on the Arduino, hence the second dimension of the array.
Feb 12, 2017 at 13:28 history answered KIIV CC BY-SA 3.0