#include "CruiseShip.hpp"
#include "iostream"
usingnamespace std;
CruiseShip::CruiseShip( int num, string name, string year ) : Ship( name, year ) {
setPassengers( num );
}
void CruiseShip::setPassengers( int num ){
passengers = num;
}
int CruiseShip::getPassengers(){
return passengers;
}
ostream& operator<< ( ostream& os, const CruiseShip& info ){
return os << "Name: " << info.getName() << endl << "Passengers: " << info.passengers << endl;
} //the error is right at the return line saying "Member function 'getName' not viable: 'this'
//argument has type 'const CruiseShip', but function is not marked const"
#include "CruiseShip.hpp"
#include "Ship.hpp"
#include <iostream>
#include <vector>
usingnamespace std;
int main() {
vector< Ship* > ptr; //I am using vector because I will add more derived
//classes later to add in here
Ship* cruise = new CruiseShip( 50, "David", "2018" );
ptr.push_back(cruise);
cout << *ptr.at[0]; // error here stating "Reference to non-static member function
//must be called
}
Also add const at in the same position on the function definitions.
The other error is that you are trying to use the at member function of the vector class, but instead of using parentheses for the argument you've used brackets.