C++ Class's Init / Shutdown

Sry this is a bit off topic but yr all gr8 programmers compared to me

im using class’s and currently have an Init and Shutdown routine so i can init and shutdown some internal things such as textures ect, i looked into constructors and destructors but they cant return values, so i decided not to use them, is thre any reason why i should?

also how do i delete a class, would this work?

HELLO Hi;
Delete Hi;

or

HELLO Hi;
free(Hi);

Thanks, sry its off topic

Read a book or two . There is far too much stuff you can do in C++ to discuss it all here.

As zeckensack said, you should read a book or two on the topic.

Just to answer the questions you had.

If you want your contructor to return error codes, use exception handling.

No, you can’t delete classes like that. delete/free is used to release dynamically allocated memory. That is, memory that is allocated at runtime. If you declare a variable/object like “HELLO Hi;”, you statically allocate memory, that is, allocated at compile time. These objects live on the stack (dynamically allocated objects lives on the heap), and is automatically deleted once they go out of scope.

If this sounds like greek to you, then again, follow zeckensack advice.

  • i didnt think u could, bad advice from a web site

Im broke do u know any good online books?

Can’t really say how good these are but I’ve seen them used at some universities and they’re free
http://www.ibiblio.org/pub/docs/books/eckel/

Thx

Originally posted by Mr_Smith:
[b]Sry this is a bit off topic but yr all gr8 programmers compared to me

im using class’s and currently have an Init and Shutdown routine so i can init and shutdown some internal things such as textures ect, i looked into constructors and destructors but they cant return values, so i decided not to use them, is thre any reason why i should?

also how do i delete a class, would this work?

HELLO Hi;
Delete Hi;

or

HELLO Hi;
free(Hi);

Thanks, sry its off topic[/b]

A good online reference would be the C++ FAQ Lite:
http://www.parashift.com/c+±faq-lite/index.html