Working in Xcode on Mac OS X Leopard in C++:
I have the following code:
class Foo{
private:
string bars[];
public:
Foo(string initial_bars[]){
bars = initial_bars;
}
}
It does not compile and throws the following error:
error: incompatible types in assignment of 'std::string*' to 'std::string [0u]'
I notice that removing the line bars = initial_bars; solves the problem.
It seems like I am not doing the assignment correctly. How could I go about fixing this problem?
EDIT:
The variable bars is an array of strings. In the main function I initialize it like this:
string bars[] = {"bar1", "bar2", "bar3"};
But it can contain an arbitrary number of members.
string bars[]itself is an error in ISO C++ compliant code - the fact that your compiler lets you do it (and, judging by the error message, treats it asstring bars[0]) means that it offers that as an extension.