CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Location
    Azerbaijan
    Posts
    74

    Do memory leaks occure in this code???

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    class Class {
    public:
        string s;
        
        string get_s()
        {
             static string _s = s;
             return _s;
        }
    };
    
    int main()
    {
        Class c;
        c.s = "Hello world";
        cout << c.get_s().c_str();
    }

  2. #2
    Join Date
    May 2004
    Location
    Norway
    Posts
    655
    Nope...

  3. #3
    Join Date
    Feb 2002
    Posts
    5,757
    In general, you should not have to worry about memory leak unless you use dynamic allocation.

    Kuphryn

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured