0

say we have a function as:

void func(const int& A){

     print_name(A);
}

which I am looking for it to print:

name: A

anyone has a suggestion for how we can define "print_name" to achieve such functionality, without explicitly writing the argument's name?

Alejandro
  • 879
  • 11
  • 27
  • 1
    You are asking for reflection, which is not yet there in C++. What is your actual issue which you are trying to solve? – Const Oct 22 '21 at 09:13
  • 2
    [You already asked this earlier](https://stackoverflow.com/q/69673047/65863), why are you asking it again? – Remy Lebeau Oct 22 '21 at 09:17
  • You can make `print_name` being a macro: `#define print_name(name) std::cout << "name: " << #name << std::endl`. This prints `name: A`: https://godbolt.org/z/1fv5Mbb5a – mch Oct 22 '21 at 09:19

0 Answers0