"Michael" <> wrote in message news:ckk4t0
> class MLine
> {
> mv3 PtOnLine;
> mv3 Direction
>
> public:
> MLine();
> const mv3& GetDirection() const
> {
> return Direction;
> }
>
> };
>
> is this OK? I appreciate that in nots of cases this can be dangerous, eg
if
> I returned (Direction *4) as a tempory object would be created with local
> scope then returning a reference to an invalid object.
It's fine and done often, as in vector<T>:

perator[] which returns a T& or
const T&. Be aware of code like this and don't write it:
const mv3& f() {
MLine m;
return m.GetDirection();
}
int main() {
cout << f().x; // crash, memory access violation!
}