Well, I finally solved the problem using operator overloading. Haven't had any more problems with that.