Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Vector< > & does't work
Vector< > & does't work [message #6745] Sun, 26 November 2006 01:58 Go to next message
Ulti is currently offline  Ulti
Messages: 108
Registered: September 2006
Experienced Member

int cache;
Vector< Item > &Ptr=Ports;
switch(T)
{
case PORT:
{
cache=PortCache;
Ptr=Ports;
}break;
case CHANNEL:
{
cache=ChannelCache;
Ptr=Channels;
}

}
if(cache!=-1)
if(Ptr[cache].selfId==key)return Ptr[cache].item;

for(int i=0;i<Ptr.GetCount();i++)
{
if(Ptr[i].selfId==key)
{
cache=i;
return Ptr[i].item;
}
}
return -1;

doesn't work.
Assertion fail at line:for(int i=0;i<Ptr.GetCount();i++)
I can't figure out why.
Re: Vector< > & does't work [message #6748 is a reply to message #6745] Sun, 26 November 2006 07:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, I am not 100% sure what is in the Ports variables, however, assert like this most likely means "pick" semantics is broken somewhere.

Ptr=Ports;

and

Ptr=Channels;

are the most likely causes, especially first - you are picking Ports to Ports or Channel to Ports (you cannot assign reference!).

I believe you wanted

Vector<Item>& Ptr = T == CHANNEL ? Channel : Ports;

Mirek
Re: Vector< > & does't work [message #6760 is a reply to message #6748] Sun, 26 November 2006 15:23 Go to previous message
Ulti is currently offline  Ulti
Messages: 108
Registered: September 2006
Experienced Member
thanks,I am so stupid Razz
Previous Topic: How to catch keyboard input?
Next Topic: How to simulate keyboard (and without focus)?
Goto Forum:
  


Current Time: Thu Mar 28 15:31:31 CET 2024

Total time taken to generate the page: 0.01734 seconds