class Farm
{
public:
Farm();
~Farm();
Object farmObj;
};
Where Object is a custom data type that holds various other custom data types. All this is good and all until I discovered my calling procedure looks something like this:
So basically, I don't like how I'm having to say farm.farmObj to access all these other elements. Any efficient way I can immediately access the object type through the identifier's name like so: farm.shader.Bind()?
you can hide farmobj. (by the way calling some class "object" is terribly unhelpful, on par with int "variable").
you could, for example, inherit object instead of has-a, which lets you say farm.Draw() directly. Is that worth doing, or do you need a has-a for some reason?
In this case there is zero overhead to creating the reference. The compiler doesn't even need to create a pointer to implement the reference - it is a synonym for Farm.farmObj and the compiler knows where it's located relative to the top of stack.
Another possibility is to create some inline functions and/or references:
Thanks for the feedback guys! Jonnin's reply had me thinking for a bit and I ended up inheriting from class Object instead. However, I'm not entirely sure whether I'm happy with it because I'm not a big fan of inheritance, but in this case inheritance seems to be fitting. dhayden's lValue reference and inline functions works out nicely as well so I think in the future I will consider all those options when I run into a problem like this one. Thanks! ^^