Đây là đoạn code mà mình chạy được trên Dev C++ nhưng lại gặp lỗi khi chạy trên visual studio. Mấy bác giúp mình sửa lại với
Code:
#include<iostream>
#include<string>
using namespace std;
class nhanvien
{
private:
string hoten;
int tuoi;
double luong;
public:
nhanvien()
{
hoten = "";
tuoi = 0;
luong = 0;
}
setthanhphan()
{
fflush(stdin);
cout << "Nhap ho ten: ";
getline(cin, hoten);
cout << "Vao tuoi: ";
cin >> tuoi;
cout << "Vao luong: ";
cin >> luong;
}
printthanhphan()
{
cout << hoten << endl;
cout << tuoi << endl;
cout << luong << endl;
}
};
int main()
{
nhanvien emp1, emp2, emp3;
emp1.setthanhphan();
emp2.setthanhphan();
emp3.setthanhphan();
emp1.printthanhphan();
emp3.printthanhphan();
system("pause");
return 0;
}
Debug:
>------ Build started: Project: 2, Configuration: Debug Win32 ------
1>Source.cpp
1>c:\users\nguye\source\repos\2\2\source.cpp(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\nguye\source\repos\2\2\source.cpp(26): warning C4183: 'setthanhphan': missing return type; assumed to be a member function returning 'int'
1>c:\users\nguye\source\repos\2\2\source.cpp(28): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\nguye\source\repos\2\2\source.cpp(32): warning C4183: 'printthanhphan': missing return type; assumed to be a member function returning 'int'
1>Done building project "2.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========