954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

obsolete binding at `a' error C++

Trying to compile a program, in my accounts.cpp I have 2 errors
accounts.cpp:240: error: name
lookup of `a' changed for new ISO `for' scoping
accounts.cpp:234: error:
using obsolete binding at `a'


here's the code

bool cAccount::IsOnline( int acctnum )
{
if (acctnum < 0) return false;

map::iterator iter_acctman;

if ((iter_acctman = acctman.find(acctnum)) != acctman.end())
{
for (int a = 0; a < now; a++)
{
if (Client[a]->GetAccNum() == acctnum)
break;
}

if (a == now)
{
SetOffline(acctnum);
return false;
}

any help would be awsome thanks :)

Nicanor
Newbie Poster
1 post since Sep 2004
Reputation Points: 10
Solved Threads: 0
 
Trying to compile a program, in my accounts.cpp I have 2 errorsp
accounts.cpp:240: error: name lookup of `a' changed for new ISO `for' scoping accounts.cpp:234: error: using obsolete binding at `a'

here's the code

bool cAccount::IsOnline( int acctnum )
  {
  	if (acctnum < 0) return false;
  
  	map<int, acctman_st>::iterator iter_acctman;
  
  	if ((iter_acctman = acctman.find(acctnum)) != acctman.end())
  	{
  		for (int a = 0; a < now; a++)
  		{
  			if (Client[a]->GetAccNum() == acctnum)
  				break;
  		}
  
  		if (a == now)
  		{
  			SetOffline(acctnum);
  			return false;
  		}
any help would be awsome thanks :)

I believe the diagnostic messages are telling you that the scope ofa should only be within the for loop -- that is, it is not available outside the for loop. So if you are using it outside the for loop, you should not declare it within the for loop.

bool cAccount::IsOnline( int acctnum )
   {
   	if (acctnum < 0) return false;
   
   	map<int, acctman_st>::iterator iter_acctman;
   
   	if ((iter_acctman = acctman.find(acctnum)) != acctman.end())
   	{
   		int a;
   		for (a = 0; a < now; a++)
   		{
   			if (Client[a]->GetAccNum() == acctnum)
   				break;
   		}
   
   		if (a == now)
   		{
   			SetOffline(acctnum);
   			return false;
   		}
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

I got this one :)
All you need is a final closing bracket at the bottom to finish your bool (function(?)

frogn8r
Newbie Poster
1 post since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You