User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 423,249 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,219 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums

Overloaded + operator not working correctly.

Join Date: Jan 2008
Posts: 72
Reputation: gerard4143 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 9
gerard4143 gerard4143 is offline Offline
Junior Poster in Training

Re: Overloaded + operator not working correctly.

  #8  
Feb 17th, 2008
Originally Posted by Jaycii View Post
If I switch it over to the way you just posted, I get the following error:

error C2662: 'getchecking' : cannot convert 'this' pointer from 'const class Account' to 'class Account &'
Conversion loses qualifiers

That is when I use this code
	Account Account::operator+(const Account &right)
	{
		Account temp;
		int temp2;
		temp2 = (savings + right.getchecking());
		temp.setTotalBalance(temp2);
		return temp;

	}


--

And the way I was trying to fix it didn't work, so back to step one, looking for what could be doing it.

-- Edit--

Looking back at that, since you input the data after running the program, none of the values are constant, which is the reason for that error I believe.


does getchecking() change Account in any way?
Reply With Quote  
All times are GMT -4. The time now is 9:47 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC