FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Problem with static variable in class





Alein_Atryda_III
I am begginer at programing and I run into small problem that I cannot overdo with any turtorial.

As stated in the topic I made static variable in class called "record" in which I store records about some random things. Each of them has ID number, which should be unique for every object created fom that class.

Ok, till now it works fine.

Using 'new' command I created table of those records, but sometimes it's fills up. When it happens I just create another, copy all records from first one to second, temporary one, then 'delete []' first one, and make new, bigger one.
Well, this should be standard thing to do, and it works fine.

My constructor has definition like this:

Code:
rekord::rekord()
{
   number_of_records++;
   ID=number_of_records;
}


When creating new tables with 'new' it automaticaly makes number_of_records grow alot, so before all described before actions I just write

unsigned int temp=rekord::number_of_records;

and after everything I do:

rekord::number_of_records=temp;

I though it would fix little bug that I get. When table of records "grows" newest ID is OK, fe. if last was 114 next one is 115, but NEXT one is higher by random number. Then it works just fine till next "grow".

I hope that someone can help me with that little info. I can post even whole source here, but it is really _bad_ so I wouldn't like to Embarassed
Related topics
PHP Validation Class
Problem with session variables
phpNuke Register new users Problem Problem
C/C++
I need advice~~! (on whom to choose!)
Easy Timestamp Question
Java classpath problem
CSS Class problem SOLVED
JAVA - random name generator
f-22 the best fighter jet in the world :)
Floating div problem
PHP and .htaccess
having difficulties understanding OOP
Website is down, please help.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.