0
Ben bir sınıf içerisindeki aşağıdaki fonksiyon var:Bir sınıf nesnesinde işlemler nasıl yapılır? C++
void solveMaze::getLoc() {
mouse m;
x = m.x;
y = m.y;
coords c(x, y);
cout << c << endl;
}
Bu, Coords sınıftır bu hayır" bir hata alıyorum < < operatörü ?:
class coords {
public:
coords(int, int);
int x;
int y;
coords& operator<<(const coords& rhs);
};
coords& coords::operator<<(const coords& rhs) {
cout << x << " " << y << endl;
}
coords::coords(int a, int b) {
x = a;
y = b;
}
aşırı doğru yolu var mı operatör < < için maç "
[Yeni başlayanlar kitabı] 'na ihtiyacınız var gibi görünüyor (http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). –
gösterdiğiniz kodda hiçbir nesne yoktur. Yöntemlerini çağırmak istiyorsanız, öncelikle bu sınıfın bir nesnesini oluşturmanız gerekir. – user463035818