Mình mới học về lập trình hướng đối tượng C++ nhưng khi làm bài tập thì gặp Undclared Identifier khi compile
Mong các bạn giúp đỡ.
student.h
#include <iostream>
#include <string.h>
using namespace std;
class student
{
private:
string name;
int age;
double money;
public:
student();
void setST();
void printST();
~student(){ }
};
student.cpp
#include "student.h"
#include "pch.h"
student::student()
{
name = "";
age = 0;
money = 0;
}
void student::setST() {
string name1;
int age1;
double money1;
fflush(stdin);
cout << "\nName: "; getline(cin, name1);
cout << "Age: "; cin >> age1;
cout << "Money "; cin >> money1;
name = name1;
age = age1;
money = money1;
}
void student::printST() {
cout << name << " " << age << " " << money << endl;
}
main.cpp
#include "student.h"
int main()
{
student st1, st2;
st1.setST();
st2.setST();
st1.printST();
st2.printST();
}