Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jan 16th, 2006, 4:46 AM   #1
Yona
Newbie
 
Join Date: Jan 2006
Posts: 2
Rep Power: 0 Yona is on a distinguished road
invalid conversion from `const IntNode*' to `IntNode*'

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
#include "IntNode.h"

//Returns sumary of list 
inline int list_sum(const IntNode *head){ 
IntNode *current; 
int sum=0; 
current=head; //ERROR APPEARS HERE//
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){ 
IntNode *current=source; //ERROR APPEARS HERE//
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!!!!
Yona is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:46 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC