C++ Temp or Local variable warning

Hi guys some problem here:

here is my overloaded operator :

const double & Waz::operator()(int i,int j) const
return ((WazImpl const)(*p))(i,j);
Where in Waz class I have : WazImpl* p; and in the class WazImpl I have an operator () const

The warning is : Warning C4172 returning address of local variable or temporary

As far as I understand I'm returning a temp variable which is destroyed somewhere else what can I do to fix it?

const double & Waz::operator()
const double Waz::operator()
Last edited on
in what line do you have that warning?
Maybe in the WazImpl operator () ?
And, if p is of type WazImpl*, why do you cast it to WazImpl const ?
Could you post a minimal compilable piece of code that reproduce the problem?
Topic archived. No new replies allowed.