I made a class with method, which returns reference to member (not good encapsulation). I'm using auto for retuned funtion
class classA
{
public:
classA(classA & rhs)
{
cout<<"copy constr A"<<endl;
};
classA() = default;
};
class classB
{
private:
classA obA;
public:
classA& getRefA(){return obA;}
};
int main()
{
classB obB;
auto ob = obB.getRefA();
}
The result is copy constr A
I understand that auto don't detect reference from function. Is auto detecting only the type without reference?