0

Hi guys,
I am trying to learn this fantastic language. My question is
Does Structure in c++ contain default constructure and destructure.
And when we allocate memory for structure by new operator like
Struct special
{
int x;
int y;
};
special = new special;

Then if special going to destroy at some point of program. Then it is destroyed just like an object of class or this is done in a different way.

Actually i was wondering to see what happened when a structure variable allocated with new operator and destroyed , also i am using a lot of structure variable in my program for which memory is allocated by new operator. Do i need to take care of freeing structure memory or not?

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Comatose
0

A Structure in C++ is a class. The only difference between the struct keyword and the class keyword, is that by default struct makes all members not explicitly identified as public. A Class makes all members (unless otherwise noted) private. That's it. No other difference. Struct has a default constructor, or you could specify one. It has a destructor too.... If you make a new struct via new, and you never call delete on it, you will have a memory leak.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.