Lỗi trong hướng đối tượng

 #include<iostream>
using namespace std;

class data {
private:
	int x;
	static int assignment_count;
	static int n;
public:
	friend ostream& operator<<(ostream &os, const data& a);
	friend istream& operator >> (istream &os, data& a);
	static void set_n(int n) {
		if (data::n == 0) data::n = n;
		else cout << "WRONG";
	}
	data& operator=(const data& a) {
		assignment_count++;
		if (assignment_count > 3 * data::n) {
			cout << "WRONG";
		}
		this->x = a.x;
		return *this;
	}
	bool operator<(const data& a) {
		return this->x < a.x;
	}
};
int data::assignment_count = 0;
int data::n = 0;

ostream& operator<<(ostream &os, const data& a) {
	return os << a.x;
}
istream& operator >> (istream &os, data& a) {
	return os >> a.x;
}
int main() {
	int n;
	cin >> n;
	data::set_n(n);
	data *A = new data[n];
	for (int i = 0; i < n; i++) {
		int x;
		cin >> A[i];
	}
	select_sort(A, n);
	for (int i = 0; i < n; i++) {
		cout << A[i] << " ";
	}
}

cho em hỏi sao khi em khai báo data nó báo lỗi “data is ambiguous”??? mọi người giúp em với :slight_smile:

Sao không cho markdown hết mà đứt đoạn thế bạn? :slight_smile:

lỗi kĩ thuật :slight_smile:

Fix lại đi cho ACE dễ nhìn :slight_smile:

Đã fix nhé :smiley: Các bạn có thể quay lại chủ đề

Bạn k đưa hàm sort nên mình bỏ dòng sort đi, xong chạy thì đoạn code của bạn chạy bình thường mà

không hiểu sao khi mình chạy nó hiện lỗi khi khai báo data bạn ơi nó ghi “data is ambiguous”

Ban thử post đầy đủ code lên xem. Tại vì mình thấy có function select_sort() nên có thể lỗi không nằm trong file này.

bỏ xài using namespace std; đi. Thêm std:: vào trước cout cin là được.

Bạn chụp ảnh màn hình lúc bị lỗi lại xem nào, chớ cứ nói vậy sao ae biết đc