Wednesday, March 17, 2010

Casting

I bloody hate casting. I have avoided it until this point.

I spent about half an hour knowing what I wanted to "return" from one of my functions, but getting a compilation error C2440, something along the lines of can't change type1 into type2. Took me a while to get why return *this was attempting to return an instance of BForm (the class I had declared and was working in) instead of BField, which was the type I was supposed to return. It was strange also because I had thought I had previously attempted casting for BField, but I suppose I must have forgotten the &. Still.... Damn you casting! I will conquer you and CRUSH you between my toes! Victory!!!

So just to recap:
BField& BForm::operator[](unsigned int index){
return (BField&)*this;
}
does nothing, but still, VICTORY!!! *kicks casting*

No comments:

Post a Comment