I am working on classes in C++.
I am basically remaking what I was doing here, but in C++.
It has gone pretty well, but I don't understand what the error member reference type 'Human *' is a pointer; did you mean to use '->'?
means. I've never used ->
and I've seen *
be used in that way (like const char *
) but I'm not too sure how it works.
The closest question that I found was this one, but the replies weren't of help.
Here is my code
#include <stdio.h>
#include <cstdlib>
#include <iostream>
using std::cout;
using std::cin;
using std::string;
class Human {
public:
string Name;
int Age;
double Height;
void Initialise(string name, int age, double height) {
this.Name = name; // Error here
this.Age = age; // Error here
this.Height = height; // Error here
}
void Grow(double rate) {
if (rate < 0) {
cout << "You can't grow at a negative rate, silly.\n";
return;
}
else if (rate >= 0.2) {
cout << "You can't grow that high, silly.\n";
return;
}
this.Height += rate; // Here too
}
};
int main() {
return 0;
}