ここではエラーが発生しています。C++でのコンパイラエラー
CruiseShip.h:10: error: expected ‘;’ before ‘::’ token
CruiseShip.cpp:8: error: expected ‘)’ before ‘name’ make: ***
[CruiseShip.o] Error 1
CruiseShip.h
CruiseShip(std::string name,std::string year, int maxPassengers)::Ship(std::string name,std::string year);
CruiseShip.cpp
CruiseShip(string name, string year, int maxPassengers)::Ship(string name, string year){
maxPassengers=0;
}
これらは、エラーが発生したラインのです。ここで
は、コードの残りの部分である: CruiseShip.cpp
#include <iostream>
#include "Ship.h"
#include "CruiseShip.h"
using namespace std;
CruiseShip(string name, string year, int maxPassengers)::Ship(string name, string year){
maxPassengers=0;
}
void CruiseShip::setPass(int maxPassengers){
this->maxPassengers=maxPassengers;
}
int CruiseShip::getPass(){
return maxPassengers;
}
void CruiseShip::print(){
cout<<"The name of the ship is "<<getName()<<endl;
cout<<"The capacity of the ship is "<<maxPassengers<<endl;
}
CruiseShip.h
#ifndef CRUISESHIP_H_
#define CRUISESHIP_H_
#include <string>
class CruiseShip: public Ship{
protected:
int maxPassengers;
public:
CruiseShip(std::string name,std::string year, int maxPassengers)::Ship(std::string name,std::string year);
void setPass(int);
int getPass();
virtual void print();
};
#endif
これはテンプレートになっていますか?それはあなたがテンプレートを使う方法ではありません。 –
私はこれらの行が何をすべきかはよく分かりません。 [mcve]を投稿してください。 –
コードを投稿してください。 –