In any programming language without pointers with garbage collector I can do
DrawLine(new Vector(0, 0), new Vector(100, 100));
But in C++ we can't if DrawLine
is not responsible for deleting its arguments, so the shortest way to invoke DrawLine
with two vectors (0,0)
and (100,100)
is:
Vector v(0, 0);
Vector w(100, 100);
DrawLine(v, w);
Is there a way to make this into a single statement? Especially if v
and w
are just arguments to that single function and no other function uses it, it seems a bit verbose. Why can't I just do something like:
DrawLine(Vector(0, 0), Vector(100, 100));