int main(int argc, char *argv[]) { Foo F; const Bar &B1 = F.getBar(); // This works. const Bar &B2 = somefunction(F); return(0); }
// ------------------------------------------------------------ void somefunction(const Foo &F) { RCP<Bar> Bptr = F.getBar(); // only allowed if getBar has const after it in definition }