Lỗi khi chạy code trên Visual Studio 2012

Tại vì trước nay quen dùng Code Block nay bắt đầu tìm hiẻu OOP nên chuyển sang VS 2012.
Không hiểu đoạn code này lỗi chỗ nào mà không chạy đc. Code Block chạy bình thường, :frowning:

#include<iostream>
using namespace std;

class BaiHocDauTien
{
	string name;
public:
	void Set(string ten)
	{
		name = ten;
	}
	string Get(string &ten)
	{
		ten = name;
		return name;
	}
};
int main()
{
	BaiHocDauTien bh;
	string ee = "Kho qua";
	bh.Set(ee);
	cout <<" "<< bh.Get(ee);
	system("pause");
	return 0;
}
2 Likes

hình như bạn thiếu hàm khởi tạo

3 Likes

BaiHocDauTien bh = new BaiHocDauTien()

3 Likes

Nó thông báo lỗi gì vậy @Lang_Khach

2 Likes
:\users\user\documents\visual studio 2012\projects\project2\project2\source.cpp(24): error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

Đây anh ơi …

Thử

#include <string>
2 Likes

ấu zìa.Thanh kiu anh iu :x :x

1 Like
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?