-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble changing class variables within method #16
Comments
I think this issue has several layers to it that we should discuss in turn. First, let me ask if you need the Second, I think the use of a Third, I agree with your suggestion to split header files and implementation more consistently than what is done right now. I do not think compile times are particularly bad at the moment, but this also has other benefits. If you want to separate them, do it one class at a time and open separate pull requests on separate branches for each of them. This makes debugging and reviewing the changes easier. |
Hi Dr. Gassmoeller. I appreciate the response! I agree that In addition, the need to access However, I think I would also like to be able to specify Just this morning, I actually found a workaround to get this to work, but I'm not sure why. I just had to declare Finally, thanks for the feedback about the header/implementation situation. If I have time this summer, I will follow your advice when editing the files in this way. |
Hi Tyler,
That sounds like a good plan.
At the moment yes, but this is something I am not too happy about anyway. The
Yes this is the correct solution (though in theory it does not have to be at the bottom of the file, it can be anywhere outside of any other scope). The reason is that the declaration (the line inside the |
Thank you! Your feedback is incredibly helpful. Thanks for taking the time to explain this to me. I'm learning a great deal about c++ with your help. I'll move |
I've implemented the option to run various sim types using the variable "mode" which is a member of the GI class. (This isn't the most descriptive name, so it will likely be changed later). It is my understanding that the best way to change the value of this variable is with a method in GI. When I attempted to change its value this way, I'm given an error. I've gotten the functionality to work using another strategy, but I don't think I'm using good coding practice (GI.h:317-318, "add-ANEOS..." branch).
The error is caused by GI.h:37 on the "add-ANEOS..." branch when the line is uncommented.
//mode = parameter_file.getValueOf("mode", 0 );
Here's the error it returns upon compilation:
I'm not sure the cause, but it may have something to do with the structure of the code. I think it's usually customary to create only the class interface in the .h file while keeping the implementation in a corresponding .cpp file (GI.cpp in this case). Currently, when we #include GI.h in main.cpp it seems to be doing the equivalent of copying and pasting all of GI.h to that location in the code, which may be causing the issue.
Am I on to anything here?
I also notice that compile times are somewhat long, and I suspect that this "copying and pasting" may be the cause because it recompiles all the code every time. If we had corresponding .cpp files for implementation of functions and classes, it may compile quicker, because it only recompiles the .cpp files that changed. (I recognize this isn't a priority right now, but just thought I'd mention it.)
The text was updated successfully, but these errors were encountered: