Linked List Question!

So i'm fairly new to pointers. What I'm trying to figure out is how can I be able to assign 2 different values such as a coefficient and an Exponent to a single node in a Linked List?

would it be something like this?

1
2
  	newNode->coefficient = coef;
	newNode->exponent = exp;
closed account (SECMoG1T)
A constructor would do it for you.

1
2
3
4
5
6
7
8
9
10
11
12
13
struct Node
{
   Node(double,double ,Node* );
   double coefficient;
   double exponent;
   Node* next;
};

Node::Node(double coef,double expo,Node* nxtnode)
 : coefficient(coef),exponent(expo),next(nxtnode){}

///usage
Node *newNode=new Node(coef,exp,link); ///where link is possibly the next node; 
Last edited on
You can actually figuring out a pointer using postman and address concept which a postman holds letter (information, anything thing you want) and an address (location where pointer pointing to). *variable_name is the postman and &variable_address is the target. Hope this will help you.
Topic archived. No new replies allowed.