I have a school project where I have to create a class with 2 attributes that default to 1. To verify that they are at 1, I have a cout before any user inputs or value manipulation. It works for the most part. What happens is that if I change the defaults to 17, the cout will retain the old values until I have an unsuccessful build (remove a semicolon from the end of the line). When I have a successful build (put that semicolon back), the cout displays the changed values. Change the values back to 1 and the same thing happens again until I have an unsuccessful build then a successful build. Are the old values getting stuck in memory somewhere?
From the sound of it, your compiler isn't recompiling Rectangle.cpp when Rectangle.h is changed. When you say you remove a semicolon from a line, is that from the header file, or the source file?
MS Visual Studio 2010 Professional. I just restarted VS and it still does it.
I'm not the world's biggest MSVC expert, but I'm guessing it's something like the minimal compilation feature or something like that, which tries to work out whether it can get away without compiling everything that depends on the header file. I would try turning that option off in the project settings, along with the precompiled header usage, and seeing if it still does it.
A clean build is when you force the compiler to delete all of the results of the previous build, and rebuild everything from scratch. So, by definition, it will always recompile your file and pick up your changes.
But you don't want to have to do that every time. Hopefully, changing those project settings will fix things.