Klasse funktioniert nicht hundert Pro



  • Hi, wieso funktioniert folgendes nicht:

    #include <iostream>
    #include <string>
    using namespace std;
    class Automobil
    {
        private:
         std::string hersteller;
    
        public:
         void herstellerAuto(const string& n);
    };
    
    void Automobil::herstellerAuto( const string& n)
    {
        hersteller = "foobar";
        cout << hersteller;
    }
    
    int main()
    {
        Automobil auto;
        auto.herstellerAuto(hersteller);
    }
    


  • weil auto ein C++ Schlüsselwort ist, du solltest mal einen anderen Namen benutzen


Anmelden zum Antworten