There's no way to do it directly from the language. Here's one example of doing it using inheritance and macros:
Code:
#ifndef _INF_DCL
#define _INF_DCL
#include <string>
struct info{std::string tp_nm, ob_nm;};
#ifndef store_info
#define store_info(_decl_t_nm, _decl_o_nm)\
_decl_o_nm.tp_nm\
=""#_decl_t_nm""\
,_decl_o_nm.ob_nm\
=""#_decl_o_nm""
#endif
#ifndef declare_info
#define declare_info(_decl_t_nm, _decl_o_nm)\
_decl_t_nm _decl_o_nm;\
store_info(_decl_t_nm, _decl_o_nm)
#endif
#endif
Then simply include the header, and derive classes from it:
Code:
#include "type_info.h"
struct some : info
{
};
int main(int argc, char *argv[])
{
declare_info(some, thing);
cout << thing.tp_nm << endl
<< thing.ob_nm << endl;
some one;
store_info(some, one);
cout << one.tp_nm << endl
<< one.ob_nm << endl;
return 0;
}