P
P
Pavel Matveev2021-11-25 14:57:05
GCC
Pavel Matveev, 2021-11-25 14:57:05

How to determine the class to which the called method belongs from C++ code?

I know that C++ has __func__ to define the name of a function, for example, when called from the myBeautifulFoo function, it returns "myBeautifulFoo", but if myBeautifulFoo is a method of the MyBeautifulClass class, then __func__ will also return myBeautifulFoo, although I would like __func__ to return something like "MyBeautifulClass::myBeautifulFoo".
And so actually a question how to receive a name of a class of a called method?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adamos, 2021-11-25
@axe_lankaster13

There are no class names in the compiled code.
There is no reflection in C++. And no, by the way.
You can check that a class is MyBeautifulClass or its descendant using dynamic_cast. And if you need something else - take another language and do not incur the wrath of St. Barbara.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question