   Class/Int Question [C++]
  I have this project that I am making:http://pastebin.org/248820It uses the Lua library, but what is messing up is just the classes, so you don't need the Lua library.  For some reason, "int ID;" in class LuaObject is messing up and changing for no apparent reason.  Here is the console app output: Curr ID:   0ID:0Curr ID:   1ID:1Curr ID:   2ID:2Lua ID: 2   Object ID: 1523656   Object ID: 1523656   Object ID: 1523656nilPress any key to continue . . .Any help please?   
  If you don't understand what I am trying to say, well all of the classes ID values are changing to 1523656 for some reason.   ;static int Object(lua_State* L) {   LuaObject newObject(L);   return 1;}When that function is invoked by your script, newObject will only exist until it runs out of scope (when the function returns). When you later try to access it with the pointer you store in Lua, it no longer exists (and contains garbage).You need to allocate it dynamically instead.   ;  Yea, it works now.  I can't believe I made that stupid mistake.  Thanks a lot!   ;  Matt, when you make small single line posts like the one above, please do not include your signature. It it very distracting to read.thanks   ;  Off-topic:I agree.  Forums should be about content, not signatures.  By that, I mean that information about the poster (such as his signature, or his avatar, etc) should not overpower nor should it distract the reader from the poster's content.  Time and time again, I find myself filtering and stripping out all the superfluous information about the poster, such as his computer specs, his internet speed, his xbox achievements, his animated avatar, and his random quote of the day, only to find out that after searching two thirds of the screen that that he posted "lol zomg wtf!"</rant>Anyways, that's what I like about gamedev.net:  strict rules for signatures and avatars, and an exceptionally high standard for quality content.  [smile]Back on-off-topic:As a rule of thumb, I would keep a signature small, and would only post a signature once per thread.   ;  Yeah. Stupid signatures...cool story bro