do I need to destroy a string in c++

if I have a string in a class, then memory is allocated. Do I have to destroy the string in the destructor? e.g.

class A {
  string Test;
  A() {
    Test = "hello world";
  }

  A(string &name) {
    Test = name;
  }

  ~A() {
    // do I have to destroy the string here?
  }
}

I'm an old c/c++ (pre stl) programmer and getting back into c++. Is the string destroyed automatically using some template magic?

tia, Dave

Answers


Yes. Strings and containers allocate/deallocate for you. HOWEVER, a container of pointers doesn't free up what those pointers point to. You have to loop through those yourself.


Need Your Help

Google Maps geoXML3: passing a placemark into it's own event listener?

javascript google-maps kml geoxml3

I'm working on an intranet project, so my KML files can't be externally available. This means I'm dependent on the geoXML3 library to parse my XML on to my Google map. However the lack of documenta...

Trouble reading input from txt file c++

c++ binary-tree

I am having trouble reading input from a text file. What I am trying to do is print multiple binary trees from a single input file. I want to print a new binary tree for each line of the input but ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.