Jos Timanta Tarigan wrote:
> Hi, 
> 
> I got question. 
> I have a constructor with parameter like this one:
> 
> Vertex4f::Vertex4f(const Vertex4f& _v){
> 
>       this->x = _v.x;
>       this->y = _v.y;
>       this->z = _v.z;
>       this->w = _v.w;
> 
> }
> 
> why do i have an error while doing this:
> 
> Vertex4f v1, v2, v3;
> v1(this->vertices[this->triangles[i].getV1()]);
> v2(this->vertices[this->triangles[i].getV2()]);
> v3(this->vertices[this->triangles[i].getV3()]);
> 
> but not error by doing this:
> 
> Vertex4f v1(this->vertices[this->triangles[i].getV1()]);
> Vertex4f v2(this->vertices[this->triangles[i].getV2()]);
> Vertex4f v3(this->vertices[this->triangles[i].getV3()]);
> 
> Isnt it just a matter of "make now assign later" kind of thing? 
> 
> 
> 
> Thanks

Because the second approach is valid C++ and the first isn't.

The first approach calls the _default_ constructor.  The next three 
lines are simply invalid C++.

If you want to assign, use the assignment operator.

BTW, the compiler automatically creates a default constructor, copy 
constructor, assignment operator, and destructor for you if you don't 
define them.  Based on what you are trying to do with your copy 
constructor, you don't seem to actually need it.

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to