Stack overflow



  • Bei folgendem Programm wird mir die Fehlermeldung "Stack overflow" um die Ohren geschmissen

    #include <iostream>
    using namespace std;
    
    class Foo
    {
    public:
    	Foo(string i) : value(i) {}
    
             friend ostream &operator<<(ostream &out, const Foo &Foo);
    private:
    	string value;
    };
    
    ostream &operator<<(ostream &out, const Foo &Foo)
    {
    	out<<Foo.value; 
    	return out;
    }
    
    Foo doSomething()
    {
    	return Foo("32");
    }
    
    int main()
    {
    	Foo x = doSomething();
    	cout<<x<<endl;
    }
    

    irgendwie verstehe ich den Grund dafür nicht ...?



  • Bei folgendem Programm wird mir die Fehlermeldung "Stack overflow" um die Ohren geschmissen
    

    Es fehlt ein #include <string>. Ansonsten ist das Programm eigentlich ok.



  • anscheinend hat der Compiler irgendwo her eine andere string klasse verwendet - wenn ich <string> inkludiere funktinoiert alles ohne probleme


Anmelden zum Antworten