Skip to main content
Arduino

Return to Answer

The correct name for the concept is, I believe, function overloading and not polymorphism
Source Link

I use a simple stupid approach...

// serial print variable type
void types(String a) { Serial.println("it's a String"); }
void types(int a) { Serial.println("it's an int"); }
void types(char *a) { Serial.println("it's a char*"); }
void types(float a) { Serial.println("it's a float"); }
void types(bool a) { Serial.println("it's a bool"); }

This is the concept of polymorphismfunction overloading where multiple functions with different parameter types are created but with the same function name. During run time, the function matching the right number of arguments and argument type(s) will get called. Hope this explanation helps.

I use a simple stupid approach...

// serial print variable type
void types(String a) { Serial.println("it's a String"); }
void types(int a) { Serial.println("it's an int"); }
void types(char *a) { Serial.println("it's a char*"); }
void types(float a) { Serial.println("it's a float"); }
void types(bool a) { Serial.println("it's a bool"); }

This is the concept of polymorphism where multiple functions with different parameter types are created but with the same function name. During run time, the function matching the right number of arguments and argument type(s) will get called. Hope this explanation helps.

I use a simple stupid approach...

// serial print variable type
void types(String a) { Serial.println("it's a String"); }
void types(int a) { Serial.println("it's an int"); }
void types(char *a) { Serial.println("it's a char*"); }
void types(float a) { Serial.println("it's a float"); }
void types(bool a) { Serial.println("it's a bool"); }

This is the concept of function overloading where multiple functions with different parameter types are created but with the same function name. During run time, the function matching the right number of arguments and argument type(s) will get called. Hope this explanation helps.

I use a simple stupid approach...

void types(String a){Serial.println("it's a String");}
void types(int a) {Serial.println("it's an int");}
void types(char* a) {Serial.println("it's a char*");}
void types(float a) {Serial.println("it's a float");} 
// serial print variable type
void types(String a) { Serial.println("it's a String"); }
void types(int a) { Serial.println("it's an int"); }
void types(char *a) { Serial.println("it's a char*"); }
void types(float a) { Serial.println("it's a float"); }
void types(bool a) { Serial.println("it's a bool"); }

This is the concept of polymorphism where multiple functions with different parameter types are created but with the same function name. During run time, the function matching the right number of arguments and argument type(s) will get called. Hope this explanation helps.

I use a simple stupid approach...

void types(String a){Serial.println("it's a String");}
void types(int a) {Serial.println("it's an int");}
void types(char* a) {Serial.println("it's a char*");}
void types(float a) {Serial.println("it's a float");} 

This is the concept of polymorphism where multiple functions with different parameter types are created but with the same function name. During run time, the function matching the right number of arguments and argument type(s) will get called. Hope this explanation helps.

I use a simple stupid approach...

// serial print variable type
void types(String a) { Serial.println("it's a String"); }
void types(int a) { Serial.println("it's an int"); }
void types(char *a) { Serial.println("it's a char*"); }
void types(float a) { Serial.println("it's a float"); }
void types(bool a) { Serial.println("it's a bool"); }

This is the concept of polymorphism where multiple functions with different parameter types are created but with the same function name. During run time, the function matching the right number of arguments and argument type(s) will get called. Hope this explanation helps.

In the Arduino IDE, you are unable to use typeof as it results in errors. Rather, you can use an alternative variable name, for example "types".
Source Link
VE7JRO
  • 2.5k
  • 19
  • 27
  • 29

I use a simple stupid approach...

void types(String a){Serial.println("it's a String");}
void types(int a) {Serial.println("it's an int");}
void types(char* a) {Serial.println("it's a char*");}
void types(float a) {Serial.println("it's a floatfloat");} 

This is the concept of polymorphism where multiple functions with different parameter types are created but with the same function name. During runtimerun time, the function matching the right no.number of arguments and argument type(s) will get called. Hope this explanation helps.

I use a simple stupid approach...

void types(String a){Serial.println("it's a String");}
void types(int a) {Serial.println("it's an int");}
void types(char* a) {Serial.println("it's a char*");}
void types(float a) {Serial.println("it's a float);} 

This is the concept of polymorphism where multiple functions with different parameter types are created but with the same function name. During runtime, the function matching the right no. of arguments and argument type(s) will get called. Hope this explanation helps.

I use a simple stupid approach...

void types(String a){Serial.println("it's a String");}
void types(int a) {Serial.println("it's an int");}
void types(char* a) {Serial.println("it's a char*");}
void types(float a) {Serial.println("it's a float");} 

This is the concept of polymorphism where multiple functions with different parameter types are created but with the same function name. During run time, the function matching the right number of arguments and argument type(s) will get called. Hope this explanation helps.

In the Arduino IDE, you are unable to use typeof as it results in errors. Rather, you can use an alternative variable name, for example "types".
Source Link
Loading
Adding a brief explanation as requested by one of the comments
Source Link
Loading
Source Link
SnakeNET
  • 209
  • 2
  • 2
Loading

AltStyle によって変換されたページ (->オリジナル) /