the code above looks fine, but when applying it into program, the error happens:
" no matching function for call to `ocean::getcoordinates (submarine &)' "
Code:
typedef struct target
{
int x;
char y;
bool hit;
target *next;
} Target;
target *newTarget()
{
target *temp;
temp = new(target);
temp->hit = false;
temp->next = NULL;
return temp;
}
class submarine
{
public:
submarine()
{
head = newTarget();
head->next = NULL;
}
void setsub(string subname, int subsize, int depth)
{
name = subname;
size = subsize;
maxdepth = depth;
}
int getcoordinates()
{
int temp;
char tempchar;
cout<<"Please enter the X coordinate. (1-10)\n";
cin>>temp;
while (!(temp >= 1 && temp <= 10))
{
cout<<"Inappropriate coordinate. Try again.\n";
cin>>temp;
}
head->x = temp;
}
private:
target *head;
int size, maxdepth;
string name;
bool destroyed;
};
class ocean
{
public:
ocean()
{
sub.setsub("Stealth Spy Sub", 1, 100);
}
int getsubcoordinates (submarine& sub)
{
sub.getcoordinates();
}
submarine sub;
private:
int score, ammo;
};
void setup(ocean& in, ocean& in2)
{
in.getcoordinates(in.sub);
}