Heat Equation C++
I am trying to develop a C++ program using the heat equation. However, I am getting errors from the program. Here is the program: I get the following error messages:
I need help in figuring out what I did wrong. Any suggestions? I will greatly appreciate any comments or suggestions.
heateq.cpp: In function `int main(int, char **)':
heateq.cpp:14: warning: initialization to `int' from `double'
heateq.cpp:15: warning: initialization to `int' from `double'
Those are warnings... what errors?
length_x and dx are both double variables. Their ratio is also a double. The compiler is warning you that you are taking this double value and using it to initialize an integer variable. To eliminate the warning, explicitly cast the value:
Note the integer truncation. Depending on your algorithm this might not be what you want.
int nx = static_cast<int>(length_x / dx);
Thank you for your help, brewbuck, you were right.