jeudi 2 novembre 2017

Wrapper functions with same return type specifier

Is it possible to create two wrapper functions x_wrap and y_wrap that would wrap int x () and int &y() with the same return type specifier and returning the types int and int &, respectively?

int g = 10;
int x() { return g; }
int &y() { return g; }

I tried using auto (using auto I have the same return type specifier for both functions) for x_wrap and y_wrap, but in this way, I would get int as returning type for both functions:

auto x_wrap() { return x(); }
auto x_wrap() { return y(); }

Maybe It's simple, but I could not solve this... I'm new with c++.

Aucun commentaire:

Enregistrer un commentaire