#ifndef ASSETS_H_INCLUDED
#define ASSETS_H_INCLUDED
#include <vector>
#include string.h>
const int ID_Max = 100;
typedef char ID[ID_Max];
struct node;
struct people{
std::vector<ID> T_ID;
std::vector<node*> Nodes;
people(ID t, node* person){
T_ID.push_back(t);
Nodes.push_back(person);
}
people(){}
};
struct node {
ID T_ID;
node* Parent;
people* leftChildren;
node* rightChild;
node(ID t, node* p, node* l, node* r) :I_ID(t), Parent(p), rightChild(r)
{leftChildren = new people(); }
};
#endif // ASSETS_H_INCLUDED
My problem is this it is interpreting ID as a char pointer when in the constructor so this is the constructor people::people(char*, node*) when I want people::people(char[ID_Max], node*) same for node. If you have advise it would be very appreciated.
If you write a function signature with an array type in it, it’s the same as using a pointer, e.g. this:
is the same as this:
That looks like it’s the root of your problem here. You might be better off with e.g. a
std::array<char,ID_Max>(in C++11), or astd::vector<char>(in C++98). You can then get a pointer to the start of the contiguous memory it contains using&cont[0]. As a minor nit, I seem to recall that the memory forvectorwasn’t strictly guaranteed to be contiguous in C++98, but it always was contiguous in practice (you could rely on it). The wording was fixed in C++03.