Class Virtual pointers

I am getting an error on line 14
Error is .cpp(14): error C3867: 'Ship::getBuilt': function call missing argument list; use '&Ship::getBuilt' to create a pointer to member
I don't really know where to place the &. Can anyone help me our and explain it to me. Thank you
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  #include <iostream>
#include <string>
using namespace std;
class Ship{
private:
	string name;
	string built;
public:
	Ship(string n, string y){
	name =n;
	built =y;}
string getname(){return name;}
string getBuilt(){return built;}
virtual void print(){cout <<"Ship name" << getname() << ", Year built:" << getBuilt << endl;}
};
class CargoShip: public Ship{
private:
	int tonnage;
public:
	CargoShip(string n, string y, int t):
		Ship(n,y){tonnage = t;}
	virtual void print(){cout <<"Ship name" << getname() << ", Maximum tonnage:" << tonnage << endl;}
};

class CruiseShip: public Ship{
private:
	int pass;
public:
	CruiseShip(string n, string y, int p):Ship(n,y){pass =p;}
	virtual void print(){cout <<"Ship name: " << getname() << ", Maximumum number passengers: " << pass << endl;}
};
int main()
{
	Ship*ships[3] = {new Ship("ship","2000"), new CargoShip("cargo", "2010", 2000), new CruiseShip("Cruise ship", "2004", 500)};
for (int i=0; i<3; i++)
{ships[i] -> print();}

	return 0;
}
You read the second half of the error message instead of the first half. Read it again:
gduong wrote:
(14): error C3867: 'Ship::getBuilt': function call missing argument list; use '&Ship::getBuilt' to create a pointer to member
14
15
16
virtual void print(){cout <<"Ship name" << getname() << ", Year built:" << getBuilt << endl;}
//                                                                                 ^
//                                                                                 () 
Oh god i am so bad. Thank you
Topic archived. No new replies allowed.