|  | 
|  | 
| back to board | Compilation error, C++ Posted by Thrall  5 Apr 2008 14:21I have:
 #include <iostream>
 using namespace std;
 (...)
 int main()
 {
 string x;
 int n;
 (...)
 cin >> x >> n;
 string good[x.size()+1];
 string tab[n], tab2[n];
 (...)
 }
 
 Dev C++ doesn't see any mistakes, but I have 5 compilation errors in these lanes:
 0d51f7eb-98bd-4754-8632-86fafd7d0b29(43): error: expression must have a constant value
 string good[x.size()+1];
 ^
 
 0d51f7eb-98bd-4754-8632-86fafd7d0b29(43): error: this operator is not allowed in an integral constant expression
 string good[x.size()+1];
 ^
 
 0d51f7eb-98bd-4754-8632-86fafd7d0b29(43): error: function call is not allowed in a constant expression
 string good[x.size()+1];
 ^
 
 0d51f7eb-98bd-4754-8632-86fafd7d0b29(47): error: expression must have a constant value
 string tab[n], tab2[n];
 ^
 
 0d51f7eb-98bd-4754-8632-86fafd7d0b29(47): error: expression must have a constant value
 string tab[n], tab2[n];
 ^
 
 compilation aborted for 0d51f7eb-98bd-4754-8632-86fafd7d0b29 (code 2)
 
 Could you tell me what's wrong?
 
 Edited by author 05.04.2008 14:25
 
 Edited by author 05.04.2008 14:26
Re: ??? #incldude <string>x.lenght()
 
 Edited by author 29.08.2011 12:37
 | 
 | 
|