Hello, everyone! I'm trying to dynamically allocate space for a string pointer in C++, but I'm having much trouble.
The code I've written is, partially, this (it's about RadixSort-MSD):
class Radix
{
private:
int R = 256;
static const int M = 15;
std::string aux[];
int charAt(std::string s, int d);
void sortR(std::string a[]);
public:
void sortR(std::string a[], int left, int right, int d);
};
And here is the problematic part:
void Radix::sortR(std::string a[])
{
int N = sizeof(a)/sizeof(std::string*);
aux = new std::string[N]; //Here is the problem!
sortR(a, 0, N-1, 0);
}
The error that apears when I try to compile my project is below, and it's about the variable "aux", which is a string pointer.
|15|error: incompatible types in assignment of 'std::__cxx11::string* {aka std::__cxx11::basic_string<char>*}' to 'std::__cxx11::string [0] {aka std::__cxx11::basic_string<char> [0]}'|
I'm a completely noob brazilian C++ student. So I can't understand what the error message is saying.
Could you help me?