Witam, mam problem z kodem. Nie odpala mi, bo ma problem z użyciem wszystkich getterów które stworzyłem:
#include <iostream>
#include <sstream>
#include <vector>
class punkt
{
private:
float X, Y;
public:
punkt(float x, float y) : X(x), Y(y) {}
float & get_X() {
return X;
}
float & get_Y() {
return Y;
}
~punkt();
};
int main() {
float t, temp_x, temp_y;
std::string input;
float a, b;
std::vector<punkt> points;
std::cin >> t;
for (int i = 0; i < t; ++i) {
std::getline(std::cin, input);
std::stringstream stream(input);
for (int j = 0; j < 3; ++j) {
stream >> temp_x >> temp_y;
points.push_back(punkt(temp_x, temp_y));
}
// y = ax + b
a = (points[0].get_Y() - points[1].get_Y()) / (points[0].get_X() - points[1].get_X());
b = points[0].get_Y() - a * points[0].get_X();
if (points[2].get_Y() == a * points[2].get_X() + b) {
std::cout << "TAK";
}
else {
std::cout << "NIE";
}
}
return 0;
}
error: invalid use of member 'float punkt::get_X()' (did you forget the '&' ?)
a = (points[0].get_Y - points[1].get_Y) / (points[0].get_X - points[1].get_X);
Co mogę z tym zrobić?