Hello, everyone! I made an account on this website because I'm having trouble with a particular program. I'm supposed to be writing a Polynomial class with a linked list to hold coefficients and an integer for the degree. I keep getting a fatal error LNK1561, though, and I don't know how to fix it. Here's the code I have so far:

#include <iostream>
using namespace std;

typedef int ElementType;

class Polynomial
{
private:
class Node
{
public:
ElementType coef;
ElementType exp;
Node * next;

Node(Node * next1 = NULL)
{
coef = 0;
exp = 0;
next = next1;
}

};
typedef Node* NodePointer;


public:
Polynomial(ElementType a, ElementType b)
{
first = NULL;
Node * temp = new Node;

temp -> coef = a;
temp -> exp = b;

first = temp;
}

void insert(ElementType a, ElementType b)
{
Node * temp1;
temp1 = new Node;
temp1 = first;

while (temp1 -> next != NULL)
temp1 = temp1 -> next;
temp1 -> coef = a;
temp1 -> exp = b;

first = temp1;



}




private:

NodePointer first;
int mySize;




};

. Can anybody help me figure out where I went wrong?

This is a linker error.

The point here is, you are telling the compiler to compile this code as an app, not a library, so it expects int main(), which is nowhere in your code.

If this is a school assignment, just adding int main() somewhere below (which you would do anyway to show that it works) should be sufficient.

Or you can build this as a library. For specific instructions how to do it, google your compiler/IDE adding "building a library" - should help.
If, for example, your IDE is MS Visual Studio, google "Visual Studio buidling a library".

You seem to be missing the main() function. Is it in another file, included in your project?

That worked. I got it to work both ways, as a library, and with adding a main function. That was a pretty rookie mistake, I guess. Thank you everybody, I'll go ahead and consider the problem solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.