#include <iostream>
#include <fstream>
#include <string>
usingnamespace std; // Global using declaration
// Global Constants -- you may use these global constants in your code
constint MAXROWS = 10; // Maximum number of rows in image
constint MAXCOLS = 10; // Maximum number of columns in image
// Function Prototypes for the functions you must implement in project01.cpp
void LoadImage(const string imagefile, int image[MAXROWS][MAXCOLS]);
int main (int argc, char * const argv[]) // Command-line arguments (more on this later)
{
...
}
#include "project01.cpp"
And I am receiving the following errors:
/home/brandon/Desktop/SawsanWilliamsCPE212Proj1/main.cpp||In function ‘int main(int, char* const*)’:|
/home/brandon/Desktop/SawsanWilliamsCPE212Proj1/main.cpp|39|warning: unused variable ‘ch’|
/home/brandon/Desktop/SawsanWilliamsCPE212Proj1/project01.cpp|14|error: array bound is not an integer constant|
/home/brandon/Desktop/SawsanWilliamsCPE212Proj1/project01.cpp|14|error: array bound is not an integer constant|
||=== Build finished: 2 errors, 1 warnings ===|
Now I know one should not use global variables but this is a project for a class of mine, and I am more of a java programmer than cpp. I do not have the luxury of changing anything but the project01.cpp file. I can not alter the main.cpp file in any way what so ever.
Hmm... Honestly, I don't know why the compiler's complaining. It shouldn't, AFAIK. You can try changing it to int image[][]. The compiler doesn't do any type checking with array bounds, anyway.
if you just compile main.cpp , it's OK,
but if you compile like this..." g++ main.cpp project01.cpp"
error will happen like "array bound is not an integer constant"
why? I am not sure that , but maybe following:
1.for single file "project01.cpp" if we just compile this . and compiler will not sure how image are, since these MAXROWS, and MAXCOLS must be real numbers.
2.for main.cpp , this file use #include "project01.cpp", MAXROWS, and MAXCOLS could be found in main.cpp when pre_compile done...
I tried this already, and was it gave an error. I cannot remember what it was at this time, but I will check on it this evening and get back to you.
1.for single file "project01.cpp" if we just complain this . and complainer will not sure how image are, since these MAXROWS, and MAXCOLS must be real numbers.
2.for main.cpp , this file use #include "project01.cpp", MAXROWS, and MAXCOLS could be found in main.cpp when pre_complain done
Is there any way you could clarify that? I am having a hard time following you.