int mas [size];
There is a problem in this line. Please guess
As other users have pointed out, the problem may be that you are trying to create a Variable Lenght Array , which is not allowed in C ++ (but almost come in C ++ 14 as Dynamic Arrays * ).
Some compilers accept VLA as an extension (no standard), so I assume that you are using one that does not have this extension, or its extension is disabled.
Donβt worry, you still have a desktop ...
#define (do not do this)
Assuming the problem is VLA, if we guarantee size as a compile-time value, the problem will be solved like this ...
// file1.hpp <-- This is now a HEADER not a CPP
constexpr
C ++ 11 introduced the constexpr * keyword that can be used to achieve your goal
// file1.hpp <-- This is now a HEADER not a CPP constexpr int size() { return 10; } // mainfile.cpp
transfer
Enumerations are compile-time constants, so you can use them as follows:
// file1.hpp <-- This is now a HEADER not a CPP enum constant { size = 10 }; // mainfile.cpp
* If someone found a better link, please let me know.
source share