Error passing an object array in C++

Asked

Viewed 122 times

0

I have the following function:

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

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

Node *grafo = new Node[numVertices];

I mean, basically, I’m trying to pass an object vector to a function. I’m calling her that:

verticeEstimativaMinima(grafo,numVertices);

But the compiler returns to me:

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

  • 1

    http://ideone.com/LWENYQ It all worked out. You need to enter a more complete code. The error is not in the parts you posted.

  • Sorry, the error was listing in the wrong compiler line, it was my own fault!

1 answer

0


The information you have passed is not clarifying the cause of your mistake.
The code snippet below compiles and executes correctly 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;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.