J
Jacob Rohde
Hi!,
I'm having problem with overloading the output operator. First I'll show you
the declaration in the header:
friend std:stream& operator<<(std:stream &os, const Vector3D
&vector);
This is declared in the public section of course.
What follows is my implementation from the .cpp file:
ostream& operator<<(ostream &os, const Vector3D &vector)
{
// Format: [x, y, z]^T
os << "[" << vector.m_x << ", " << vector.m_y << ", " << vector.m_z <<
"]^T";
return os;
}
When I compile I get
_
error C2248: 'math::Vector3D::m_x' : cannot access private member declared
in class 'math::Vector3D'
_
Which I don't understand AT ALL. The operator is declared in the class and
should as such could access private members, right?
I'm having problem with overloading the output operator. First I'll show you
the declaration in the header:
friend std:stream& operator<<(std:stream &os, const Vector3D
&vector);
This is declared in the public section of course.
What follows is my implementation from the .cpp file:
ostream& operator<<(ostream &os, const Vector3D &vector)
{
// Format: [x, y, z]^T
os << "[" << vector.m_x << ", " << vector.m_y << ", " << vector.m_z <<
"]^T";
return os;
}
When I compile I get
_
error C2248: 'math::Vector3D::m_x' : cannot access private member declared
in class 'math::Vector3D'
_
Which I don't understand AT ALL. The operator is declared in the class and
should as such could access private members, right?