Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


Well, I got most of the project done. I am sort of confused with constructor / destructors though. I should work with it more until I understand the concept more, but I did go ahead and finish chapter 7.

Anyway, I love working on these programs, really gets the mind working :)
Sign in to follow this  


Recommended Comments

The constructor is called when you create an object. If you don't specify a constructor, the compiler defines one itself. You can overload constructors too. If you have some kind of string class, you could have a contructor that takes no arguments (just creates an empty string). Then you could also have a constructor that takes one argument, a string (the "abcdefg" kind of string in this case, not std::string), and initializes your string with that literal. The first constructor I mentioned would be created with "myString someString;", but the second one would be with "myString someString("Test");". That's basically a constructor for you.

Destructors are the same way, except you can't overload them, and they don't take parameters. If you try to have an argument with a destructor, they'll explode. [lol] [grin]

Share this comment

Link to comment
In a nutshell, constructors are where you create objects and destructors are when you destroy objects (such as where you delete the memory you've allocated, etc).

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!