Scope issue when passing property of object into method. (opencv related)
===

Just learning C++, encountered an issue that i'm not really sure why the following is the case.

Doesn't work 

    ChildObject in = myObject.getObjFromVector(0);
    ChildObject out = myObject.getObjFromVector(1);
    doSomething(in.property, out.property); // void doSomething(Thing &in, Thing &out)

    where 
    ChildObject& getObjFromVector(int index)

Works 

    process(myObject.getObjFromVector(0).property, myObject.getObjFromVector(1).property);



In case your wondering, though i don't think its relevant, Thing is Mat from opencv. This question however is about why the above works in one way but not the other.


Interestingly http://stackoverflow.com/questions/10060050/which-is-more-performant-passing-a-method-the-entire-object-or-a-property-of-t suggests that both should work, or at least be acceptable. I'm definately doing something wrong though and this might be down to something in openCV i'm not aware off.


edit:
I'm effectively carrying out some image manipulation on the .property value. like 

    process (Mat &src, Mat &out){
    ...
    pyrDown(src, result, Size(src.cols / 2, src.rows / 2));
    ...

WHen its not working, i'm not seeing the pyrDown take effect. 