Yes. In C++, a struct is almost identical to a class, the only difference is that by default the members of a struct are public while the members of a class are private. You can write a constructor for your struct just like you would for the class.

abachler: "A great programmer never stops optimizing a piece of code until it consists of nothing but preprocessor directives and comments "

structs can certainly have constructors, destructors and member functions in C++ (they can not in C).

in fact, so long as you are careful to specify public/private appropriately, you could go through a C++ program and replace the word class with the word struct and the program would compile exactly the same.

Last edited by jEssYcAt; 02-23-2008 at 11:19 PM.

abachler: "A great programmer never stops optimizing a piece of code until it consists of nothing but preprocessor directives and comments "