2 つの個別のリンク リストを作成し、それらを比較する必要があります。ただし、コンストラクターに対して同じ演算子のオーバーロードを使用して 2 番目のリストを作成しようとすると、エラーが発生します。
「polynomial2* 型の値は、polynomial* 型のエンティティの初期化には使用できません」
そのセクションのコードは次のとおりです。
ヘッダ:
#include <iostream>
#include <string>
using namespace std; 
struct polynomial
{ 
    polynomial();
    polynomial(string newCoefficient, string newPower, polynomial *nextPtr);
    string coefficient;
    string power;
    polynomial *next; 
};
struct polynomial2
{ 
    polynomial2();
    polynomial2(string newCoefficient2, string newPower2, polynomial2 *nextPtr2);
    string coefficient2;
    string power2;
    polynomial *next2; 
};
class linkedList
{
public:
    linkedList();
    void callFunctions();
private:
    polynomial *head;
    polynomial2 *head2;
    void makeList(polynomial *head, polynomial2 *head2);
    void showList(polynomial *head);
    void compareNodes(polynomial *head, polynomial2 *head2);
};
#endif
/* defined(__Assignment3__Polynomial__) */
.CPP コード:
linkedList::linkedList()
{
    head = 0; 
};
polynomial::polynomial()
{
    coefficient = " "; 
    power = " "; 
    next = NULL;
};
polynomial2::polynomial2()
{
    coefficient2 = " "; 
    power2 = " "; 
    next2 = NULL
};
polynomial::polynomial(string newCoefficient, string newPower, polynomial *nextPtr )
    :
coefficient(newCoefficient),
    power(newPower), 
    next(nextPtr) 
{}
polynomial2::polynomial2(string newCoefficient2, string newPower2, polynomial2 *nextPtr2)
    :
coefficient2(newCoefficient2),
    power2(newPower2), 
    next2(nextPtr2)
{}
エラーは、.cpp ファイルの最後の行の "next2(nextPtr2)" に表示されます。「nextPtr2」には下線が引かれています