Error passing a vector of objects in C ++ [closed]

0

I have the following function:

int verticeEstimativaMinima(Node *grafo, int numVertices){}

And in my function main , I have the following line of code:

Node *grafo = new Node[numVertices];

That is, I'm basically trying to pass an array of objects to a function. I'm calling it this way:

verticeEstimativaMinima(grafo,numVertices);

But the compiler returns me:

  

[Error] could not convert 'graph' from 'Node *' to 'Node'

    
asked by anonymous 02.10.2014 / 16:41

1 answer

0

The information you have passed is not clarifying the cause of your error. The code snippet below compiles and correctly runs online .

struct Node
{
    char c;
    int i;
};

int verticeEstimativaMinima(Node * grafo, int numVertices){ return 0;}

int main()
{    
   Node *grafo = new Node[4];
   verticeEstimativaMinima ( grafo, 4);   
   cout << "Hello World" << endl;    
   return 0;
}
    
02.10.2014 / 17:12