I write my own libraries to do some simple tasks.
You can find it here
Recently I made some changes to function "show()"
Replaced a lot overloaded to template
And that works well... if you specific 2+ parameters.
As you can see in src/Seg7List.cpp, the first parameter is template, and both the other 2 parameters have a default value.
You can try to clone that library and try compiling that example "BasicDisplay" in the library.
If I just pass one parameter, error occurred, and it looks like this:
undefined reference to `void Seg7List::show<char const*>(char const*, unsigned long, int)'
Is there a way to solve this?
Leave a comment below or start an issue on GitHub, thanks a lot.
Why do you have a template version when the first thing you do is convert whatever type was passed in to a String? You never care what the type actually is, as long as the String class can convert the type to a String. So, get rid of the templated version, and just make the method take a String.
PaulS:
Why do you have a template version when the first thing you do is convert whatever type was passed in to a String? You never care what the type actually is, as long as the String class can convert the type to a String. So, get rid of the templated version, and just make the method take a String.
I changed that, and this time I got following error:
converting to 'String' from initializer list would use explicit constructor 'String::String(char)'
And the reason that I use template is that it can't take a double as its parameter
no matching function for call to 'Seg7List::show(double)'
And the reason that I use template is that it can't take a double as its parameter
What can't? The show() method should take a String. It will then be YOUR responsibility to pass it a String. How you convert a double to a String is entirely up to you.
double pi = 3.14159'
String piStg = convertToString(pi);
String convertToString(double val)
{
String uselessWasteOfResources = "a small slice, please";
return uselessWasteOfResources;
}