Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualpinebanana

Posted 23 January 2013 - 12:56 AM

The compiler is probably getting confused if you inline it and it isn't available to all translation units (i.e. you need to define it in the class declaration or in the header)?

haha yes that solved it... stupid me for not seeing it myself
i just removed the 'inline' keyword. took me some time googling to fully understand whats going on, but i get it now smile.png

this can be closed i guess

thanks a plenty to everyone again, <3 this forum

 

 

EDIT: i also moved to returning a reference for assignments:

Vector3 &Vector3::operator=(const Vector3 &v)
{
	x = v.x;
	y = v.y; 
	z = v.z;
	return *this;
}

i assume this the proper way to do this?

Shouldn't it be:

 

 

Vector3& Vector3::operator=(const Vector3& v)
{
       if(this != &v)
       {
             x = v.x;
             y = v.y;
             z = v.z;
       }
       
       return *this;
}

 

Oh and why not use a pre-made math library such as GLM?


#2pinebanana

Posted 23 January 2013 - 12:55 AM

The compiler is probably getting confused if you inline it and it isn't available to all translation units (i.e. you need to define it in the class declaration or in the header)?

haha yes that solved it... stupid me for not seeing it myself
i just removed the 'inline' keyword. took me some time googling to fully understand whats going on, but i get it now smile.png

this can be closed i guess

thanks a plenty to everyone again, <3 this forum

 

 

EDIT: i also moved to returning a reference for assignments:

Vector3 &Vector3::operator=(const Vector3 &v)
{
	x = v.x;
	y = v.y; 
	z = v.z;
	return *this;
}

i assume this the proper way to do this?

Shouldn't it be:

 

Vector3& Vector3::operator=(const Vector3& v)
{
       if(this != &v)
       {
             x = v.x;
             y = v.y;
             z = v.z;
       }
       
       return *this;
}


#1pinebanana

Posted 23 January 2013 - 12:54 AM

The compiler is probably getting confused if you inline it and it isn't available to all translation units (i.e. you need to define it in the class declaration or in the header)?

haha yes that solved it... stupid me for not seeing it myself
i just removed the 'inline' keyword. took me some time googling to fully understand whats going on, but i get it now smile.png

this can be closed i guess

thanks a plenty to everyone again, <3 this forum

 

 

EDIT: i also moved to returning a reference for assignments:

Vector3 &Vector3::operator=(const Vector3 &v)
{
	x = v.x;
	y = v.y; 
	z = v.z;
	return *this;
}

i assume this the proper way to do this?

Shouldn't it be:

 

 
</p><pre>
Vector3 &Vector3::operator=(const Vector3 &v)
{
        if(this != &v)
        {
                	    x = v.x;
                            y = v.y;
                            z = v.z;
        }

	return *this;
}</pre>

PARTNERS