Arduino: 1.8.2 (Windows 10), TD: 1.36, Board: "Arduino/Genuino Uno"
C:\Users\tr001221\Documents\Portable Arduino 1.8.2\arduino-1.8.2\portable\sketchbook\yyy\yyy.ino: In function 'void setup()':
yyy:24: error: request for member 'printValues' in 'classInstance1', which is of non-class type 'myClass()'
classInstance1.printValues();
^
exit status 1
request for member 'printValues' in 'classInstance1', which is of non-class type 'myClass()'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
However, if instead I try to call the ‘printValues()’ method on the other class instance:
Note: The ": initializers" syntax is required if the target variable is 'const' but for regular variables I find it easier to read and understand a traditional assignment:
Turns out either constructor method causes a compile error if I don’t get the syntax right.
In order instantiate a variable using the “no parameter” constructor, it looks like the syntax needs to be:
myClass classInstance1;
It won’t compile if I try this:
myClass classInstance1();
I guess this makes sense, I just thought there might be some symmetry with the versions of the constructor that do take parameter(s). Meaning, if this is OK:
It's not OK for creating an instance because it looks just like a function prototype for a function that takes no arguments and returns an instance of myClass. Similarly, if the parens contain a declaration then it IS a function prototype: