Going from struct to class

I've been working on a path-tracer for some time, and all along I've used structs instead of classes for vectors and matrices. Today I changed all of them to classes instead, changing none of the actual function bodies themselves, and the results were miserable to say the least. Here's a render form before the change:


And here's the same render after:


Needless to say I'm not asking for anyone to look through all my code and find out what's wrong, but I thought I'd ask if any of you have any ideas about why this is happening, considering that none of the actual function-bodies have been changed, except for what little is needed to make the change from class to struct.
We'd have to see the code. Everything else is just guessing.

(My guess is that you have introduced some transformation when copying objects.)
Just to add on, if you have copied correctly, then just put private / public access specifiers explicitly and the code should work.

The only difference between a struct and a class is that in struct the members are public by default and in a class they are private (by default).
I wasn't entirely correct in my original post. Since I went from a C-style struct to a class, some of the function bodies were changed, for example

Vector3 subtract(const Vector3 *a, const Vector3 *b) {
	return newVector3(a->x-b->x, a->y-b->y, a->z-b->z);

got changed to
Vector3 Vector3::subtract(const Vector3 &v) const {
	return Vector3(x-v.x, y-v.y, z-v.z);

What I meant was that none of the logic was changed. The codebase is quite large at this point, I could post the vector class here, but the other changes that were made are too pervasive, you would have to read through the entire thing...
Then you need to learn to create small testcases.
ne555: I had done a bit of that already, but not enough. I wrote a few more tests and found the error! There was one function which created new variables with the same name as the class variables, which caused that function to fail. Thanks all! :)
Topic archived. No new replies allowed.