Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 131,528 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,091 people online right now. Registration is fast and FREE... Join Now!




invalid conversion of const intnode to intnode

 
Reply to this topicStart new topic

invalid conversion of const intnode to intnode

yona
post 16 Jan, 2006 - 03:12 AM
Post #1


New D.I.C Head

*
Joined: 16 Jan, 2006
Posts: 1


My Contributions


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!!!!
User is offlineProfile CardPM

Go to the top of the page


gregoryH
post 13 Oct, 2006 - 04:09 PM
Post #2


D.I.C Regular

Group Icon
Joined: 4 Oct, 2006
Posts: 417



Dream Kudos: 50
My Contributions


could you attach your course code (all of it) as a zip...

thanks
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 13 Oct, 2006 - 05:44 PM
Post #3


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,158



Thanked 31 times

Dream Kudos: 25
My Contributions


The assignment may have been due already... wink2.gif
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/20/08 01:27AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month