On 2008-08-30 16:49:56 -0400,
mcarthum@gmail.com said:
Quote:
I have a class declared in a header file as follows:
>
class Vector3{
public:
int x,y,z;
Vector3(int inx, int iny, int inz);
};
>
And I define the class in a source file:
>
class Vector3{
public:
int x,y,z;
Vector3(int inx, int iny, int inz){
x = inx;
y = iny;
z = inz;
}
};
>
This definition says that the constructor is inline, so it's not
visible outside the source file where this definition occurs.
Ordinarily, an inline constructor is defined in a header file, and an
out of line constructor is defined out of line in a source file, like
this:
Vector3::Vector3(int inx, int iny, int inz){
x = inx;
y = iny;
z = inz;
}
Or, slightly better in this case but in general much better:
Vector3::Vector3(int inx, int iny, int inz)
: x(inx), y(iny), z(inz)
{
}
--
Pete
Roundhouse Consulting, Ltd. (
www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(
www.petebecker.com/tr1book)