2016-05-02 9 views
-1

Der Versuch, mein Programm zu debuggen und einige Fehler zu bekommen, kann ich nicht herausfinden.Compiler Fehler C++

CruiseShip.h: In constructor ‘CruiseShip::CruiseShip(std::string, std::string, int)’: 
CruiseShip.h:16: error: expected primary-expression before ‘,’ token 
CruiseShip.h:16: error: expected primary-expression before ‘)’ token 
CruiseShip.h:16: error: expected ‘{’ at end of input 
CruiseShip.cpp: At global scope: 
CruiseShip.cpp:11: error: expected ‘)’ before ‘n’ 
CruiseShip.cpp: In function ‘void print()’: 
CruiseShip.cpp:20: error: ‘passengers’ was not declared in this scope 

CruiseShip.h

#ifndef CRUISESHIP_H 
    #define CRUISESHIP_H 
    #include "Ship.h" 
    #include <string> 
    using namespace std; 

    //class Ship; 

    class CruiseShip:public Ship{ 
     private: 
      int passengers; 
      Ship::Ship s; 
     public: 


      CruiseShip(string, string, int):Ship(string,string); 

     virtual void print(); 
    }; 

    #endif 

CruiseShip.cpp

#include "CruiseShip.h" 
    #include "Ship.h" 

    #include <iostream> 

    using namespace std; 

    Ship s; 


     CruiseShip(string n, string y, int p) : Ship(n,y) 
     { 
     passengers=p; 
     } 

     void print() 
     { 
     cout<<"Name: "<<s.getName()<<"\nMaximum passengers:"<<passengers<<endl; 
     cout<<"-------------------------"<<endl; 
     } 
+2

Sie wahrscheinlich ein [gutes Buch über einige Grundlagen] konsultieren zu ändern (http://stackoverflow.com/questions/388242/the-definitive-c (Buchführer und Liste) oder Tutorial, bevor Sie Ihre nächste Frage stellen. Das System verbietet es, sehr schnell schlechte Fragen zu stellen. –

Antwort

2

Sie müssen nicht und darf nicht Initialisiererliste erklären.

Try

CruiseShip(string, string, int):Ship(string,string); 

zu

CruiseShip(string, string, int); 
+0

Okay, macht Sinn, danke Kumpel! –