c++ - Particular form of bind temporary to const reference has no effect -


given

struct {     void a(void) { std::cout << "a" << std::endl; } };  const &a = a(); /* make copy of , bind */ const &b(a());  /* nothing */  a.a(); /* prints */ b.a(); /* error, same if b doesn't exist */ 

why second form of "bind temporary const reference" seem equivalent no-op?

this case of most vexing parse, you're declaring function rather const reference a.

you fix using c++11 uniform initialization:

const &b{a()}; 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -