How do I use a class array as a pointer? I tried in several ways, but C ++ would not let me compile errors.
An example of the class (Just an example, the class I need to use is thousands of times larger than this)
class Pessoas
{
private:
std::string Nome;
public:
std::string getNome() const { return this->Nome; }
void setNome(std::string Nome) { this->Nome = Nome; }
};
Pessoas pessoas[1000]; // Forma atual que estou utilizando, compila corretamente, porém eu preciso que ela fique allocada no heap
Pessoas* pessoas = new Pessoas[1000]; // Compila corretamente, porém, eu tenho que utilizar o operador . para acessar os membros, o que me parece estranho pois geralmente eu utilizo o operador ->, dessa forma ela está sendo allocada no heap?
Is the second form being allocated in the heap? If it's not like I do to allocate in the heap?
An example of how I wanted to leave (without overloading operators, as if it were a pointer):
pessoas[1]->setNome("Fulano");
pessoas[2]->setNome("Sicrano");
I'm trying to store the class in the heap because as the class is big I think it will not fit in the stack, another reason is also that I need the class data to be up to the end of extremely large functions which I believe does not happen no stack.