I'm trying to pass the value contained in the object obj to the function addnode but I get a code blocks error that it can't convert obj from mos* to mos. How could this be rewritten to pass a pointer to the function addnode
The code is as shown below.
#include <iostream>
#include <sstream>
using namespace std;
struct mos
{
int x;
float y;
mos * next;
};
void addnode (mos);
int main()
{
mos * obj = new (nothrow) mos;
//Check for proper memory allocation.
if (obj == NULL)
{
cout << "\nProblem assigning memory.\n";
}
else
{
cout << "\n Memory well allocated.\n Result is: " << obj;
}
addnode(obj);
return 0;
}
void addnode (mos * head)
{
//code that adds a node to the last node in the linked list.
}