hi,
i am working on this assignment. i have a header IntNode given and based on this header i have to make a new header InrNodeEx in which i have to make the three following functions :
-inline int list_sum(const IntNode *head)
Returns sumary of list
-inline void list_multilpy_withNumber(IntNode *head, int number)
Multiplies all elements of list with a number
-inline IntNode* list_from_multiplyWithNumber(const IntNode* source, int number)
Multiplies all elements of list with a number without changing the source list
IntNodeEx i've written is the following
CODE
#include "IntNode.h"
//Returns sumary of list
inline int list_sum(const IntNode *head){
IntNode *current;
int sum=0;
current=head;
while(current){
sum = sum + current->data;
current=current->getNext();
}
return sum;
}
//Multiplies all elements of list with a number
inline void list_multilpy_withNumber(IntNode *head, int number){
IntNode *current=head;
while(current){
current->data=(current->data)*number;
current=current->getNext();
}
}
//Multiplies all elements of list with a number without changing the source list
inline IntNode* list_from_multiplyWithNumber(const IntNode* source, int number){
const IntNode *current=source;
IntNode *target=0;
while(current){
list_insert(&target, new IntNode((current->data)*number));
current=current->getNext();
}
return target;
}
the problem is that when i call the functions list_sum(const IntNode *) and list_from_multiplyWithNumber(const IntNode*, int) the compiler shows the following mistakes
In function `int list_sum(const IntNode*)':nvalid
conversion from `const IntNode*' to `IntNode*'
In function `IntNode* list_from_multiplyWithNumber(const IntNode*, int)':invalid conversion from `const IntNode*' to `IntNode*'
which is absolutely normal to happen but i really can't figure out any way to deal with these errors.
Can anybody suggest any solution?
thanx for ur time!!!!