Why only some of the methods of a template are allowed to be defined outside of class? [message #1821255] |
Sat, 08 February 2020 08:10  |
Eclipse User |
|
|
|
Here is the class for 7-segment LED display (see attachments).
Here is how it is instantiated:
const byte pinSeg[7] = {2, 3, 4, 6, 7, 8, 9};
const byte pinPos[4] = {10, 11, 12, 13};
const byte pinCathode = A0;
const byte pinRed = 11;
const byte pinGreen = 13;
UVCounterDisplay<7, 4> disp(pinSeg, pinPos, pinRed, pinGreen, pinCathode);
When I move the definition of the method "display()" into a .cpp file the compiler starts to complain: "..undefined reference to `UVCounterDisplay<(unsigned char)7, (unsigned char)4>::display()'".
What makes this method special comparing to "setGreen()" and "setRed()" methods (which are defined in the .cpp file)?
[Updated on: Sat, 08 February 2020 08:14] by Moderator
|
|
|
|
|
|
|
|
|
Re: Why only some of the methods of a template are allowed to be defined outside of class? [message #1821267 is a reply to message #1821265] |
Sun, 09 February 2020 13:45  |
Eclipse User |
|
|
|
Yes, solved the problem of handling template (macro) expansions.
Too bad they didn't consult with you first.
There was an early attempt to automatically locate the templates.
It used the 'export' keyword.
Few compiler writers implemented it so it was removed from the standard in 2011 because it was unnecessary.
Quote: point me to a family of low cost low power MCUs that run a human-friendly programming language
"human friendly"?
No CPU runs on any programming language.
Instead all CPUs use combinations of bits to specify what is to be done.
Programming languages are for humans to make programming "human friendly".
In any case, this is way off topic for this forum.
Take it up on reddit.
[Updated on: Sun, 09 February 2020 16:31] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03798 seconds