GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 07-Sep-2004, 18:08
soccer022483 soccer022483 is offline
New Member
 
Join Date: Mar 2004
Posts: 17
soccer022483 is on a distinguished road

Error??


can someone compile & run this and tell me what the error means...

http://www.anova-design.com/misc/largeint.h
http://www.anova-design.com/misc/main.cpp

main.cpp contains main, and it inlcludes largeint.h

Thanks,

Austin
  #2  
Old 07-Sep-2004, 19:56
soccer022483 soccer022483 is offline
New Member
 
Join Date: Mar 2004
Posts: 17
soccer022483 is on a distinguished road
Exclamation

What's the problem?


Does no one know the answer to http://www.gidforums.com/t-3587.html?
  #3  
Old 07-Sep-2004, 20:34
crystalattice's Avatar
crystalattice crystalattice is offline
Flame War Instigator
 
Join Date: Apr 2004
Location: San Diego
Posts: 1,534
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Don't get upset.


Quote:
Originally Posted by soccer022483
Does no one know the answer to this?
What error messages are you getting? What you get may not be what other people get.
__________________
Common Sense v2.0-Striving to make the world a little bit smarter.
  #4  
Old 07-Sep-2004, 20:47
soccer022483 soccer022483 is offline
New Member
 
Join Date: Mar 2004
Posts: 17
soccer022483 is on a distinguished road
Quote:
Originally Posted by crystalattice
What error messages are you getting? What you get may not be what other people get.

Compiling...
main.cpp
c:\documents and settings\austin\my documents\desktop\desktop\largeint\largeint.h(146) : error C2662: 'Compare' : cannot convert 'this' pointer from 'const class LargeInt' to 'class LargeInt &'
Conversion loses qualifiers
c:\documents and settings\austin\my documents\desktop\desktop\largeint\largeint.h(149) : error C2662: 'Divide' : cannot convert 'this' pointer from 'const class LargeInt' to 'class LargeInt &'
Conversion loses qualifiers
c:\documents and settings\austin\my documents\desktop\desktop\largeint\largeint.h(161) : error C2662: 'Compare' : cannot convert 'this' pointer from 'const class LargeInt' to 'class LargeInt &'
Conversion loses qualifiers
c:\documents and settings\austin\my documents\desktop\desktop\largeint\largeint.h(163) : error C2662: 'Compare' : cannot convert 'this' pointer from 'const class LargeInt' to 'class LargeInt &'
Conversion loses qualifiers
c:\documents and settings\austin\my documents\desktop\desktop\largeint\largeint.h(17 : error C2662: 'Compare' : cannot convert 'this' pointer from 'const class LargeInt' to 'class LargeInt &'
Conversion loses qualifiers
c:\documents and settings\austin\my documents\desktop\desktop\largeint\largeint.h(180) : error C2662: 'Compare' : cannot convert 'this' pointer from 'const class LargeInt' to 'class LargeInt &'
Conversion loses qualifiers
Error executing cl.exe.

main.obj - 6 error(s), 0 warning(s)
  #5  
Old 08-Sep-2004, 00:28
aaroncohn's Avatar
aaroncohn aaroncohn is offline
Regular Member
 
Join Date: Feb 2004
Location: Bay Area, CA.
Posts: 564
aaroncohn is a jewel in the roughaaroncohn is a jewel in the roughaaroncohn is a jewel in the rough
[edit]Thread was merged.[/edit]

You would be best off asking whoever it was that wrote largeint.h.
__________________
-Aaron
  #6  
Old 08-Sep-2004, 01:36
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 889
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough
Quote:
Originally Posted by soccer022483
can someone compile & run this and tell me what the error means...

largeint.h
main.cpp

main.cpp contains main, and it inlcludes largeint.h

Thanks,

Austin

They mean that you can't change a member data of the object in a const member function:

CPP / C++ / C Code:
LargeInt LargeInt::operator/( LargeInt const& rhs ) const
{
    if( rhs < LargeInt("0") )
        throw overflow_error("ERROR: Overflow in operator/!");    
    
	if( 0==Compare(number, LargeInt("0").number) )
		return LargeInt("0");
	LargeInt oLNQ, oLNDummy;
	Divide(number, rhs.number, oLNQ.number, oLNDummy.number);
	oLNQ.sign = (-1==sign)&&(-1==rhs.sign)||(1==sign)&&(1==rhs.sign) ? 1 : -1;
	return oLNQ;
}

You pass to Compare LargeInt(0), and in it you MODIFY private member data vector<char> number;. You can't do this! I made it run by removing most of your consts....not necesarilly the way to go, but in the time given... (I'm a busy man )

Regards,
Luci
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #7  
Old 08-Sep-2004, 10:22
soccer022483 soccer022483 is offline
New Member
 
Join Date: Mar 2004
Posts: 17
soccer022483 is on a distinguished road
Quote:
Originally Posted by LuciWiz
They mean that you can't change a member data of the object in a const member function:

CPP / C++ / C Code:
LargeInt LargeInt::operator/( LargeInt const& rhs ) const
{
    if( rhs < LargeInt("0") )
        throw overflow_error("ERROR: Overflow in operator/!");    
    
	if( 0==Compare(number, LargeInt("0").number) )
		return LargeInt("0");
	LargeInt oLNQ, oLNDummy;
	Divide(number, rhs.number, oLNQ.number, oLNDummy.number);
	oLNQ.sign = (-1==sign)&&(-1==rhs.sign)||(1==sign)&&(1==rhs.sign) ? 1 : -1;
	return oLNQ;
}

You pass to Compare LargeInt(0), and in it you MODIFY private member data vector<char> number;. You can't do this! I made it run by removing most of your consts....not necesarilly the way to go, but in the time given... (I'm a busy man )

Regards,
Luci

Thank you so much. I really appreciate your help.

Austin
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Operator Overloading: << aaroncohn CPP / C++ Forum 36 07-Dec-2004 19:22
link error? pablowablo CPP / C++ Forum 14 19-Jun-2004 10:00
OpenGL always reports error mvt OpenGL Programming 2 04-Jun-2004 06:42
Visual C++ 6 Compiler error vip3r CPP / C++ Forum 2 13-Apr-2004 14:34
[script] E-mail webmaster error page BobbyDouglas PHP Code Library 0 19-Aug-2003 20:10

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 19:39.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.