オブジェクト obj に含まれる値を関数に渡そうとしていますが、からにaddnode
変換できないというコード ブロック エラーが発生します。関数へのポインターを渡すためにこれをどのように書き直すことができるでしょうか
。コードは次のとおりです。obj
mos*
mos
addnode
#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.
}