Is deconstructers bad :S ?

Discussion about everything. New games, 3d math, development tips...
Post Reply
Lil Margin
Posts: 212
Joined: Sun Jul 19, 2009 4:24 am
Location: Netherlands Antilles, Curacao

Is deconstructers bad :S ?

Post by Lil Margin »

Hey ya'll,
I notice that when i use a deconstructer it automatically gets called at startup of the code generation thingy...
so my question is : if it destructs at startup, why use it :S ?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

hu ??? :shock:
the destructor should only get called when you destroy the object but the constructor when you create the object !!!
and both are often usefull and needed... ;)

I guess there is something wrong with your code...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Lil Margin
Posts: 212
Joined: Sun Jul 19, 2009 4:24 am
Location: Netherlands Antilles, Curacao

Post by Lil Margin »

no lol its not my code, make a class of the irrlicht device.
create it in the constructor and drop it in the deconstructer, then when you usally call of device-drop() call the deconstructer...and you will get an unhandeled exception.
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

Code: Select all

class A
{
   IrrlichtDevice* Device;

public:
   A()
   {
       cout << "A()" << endl;
       Device = createDevice();
   }

   ~A()
   {
       cout << "~A()" << endl;
       if( Device ) Device->drop();
   }
};

int main()
{
   A a;

   return 0;
}
Should work. Maybe you can show some code ?
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

deconstructer... I'm never going to get that word out of my mind now!

The rule for Irrlicht is - only call drop() when you created with a function starting with create, when you used new or when you did a grab().
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Lil Margin
Posts: 212
Joined: Sun Jul 19, 2009 4:24 am
Location: Netherlands Antilles, Curacao

Post by Lil Margin »

@Sylence my code is familiar to yours...

@CuteAlien, so a deconstructer doesn't work...right?
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

There is no such a thing as 'deconstructer'.
Please read up on destructors.
"Whoops..."
Lil Margin
Posts: 212
Joined: Sun Jul 19, 2009 4:24 am
Location: Netherlands Antilles, Curacao

Post by Lil Margin »

hahahaha destructer, lol funny me XD
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Lil Margin wrote:hahahaha destructer, lol funny me XD
I thought my post nade this clear, but maybe it was a litle bit too subtile... :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply