01/10/2018, 00:05
Header file trong C++
//Student.h
#pragma once
#include "Point.h"
#include<string>
using namespace std;
class Student
{
private:
string id;
string name;
string address;
string sex;
Point point;
public:
Student();
~Student();
void setId(string);
string getId();
void setName(string);
string getName();
void setAddress(string);
string getAddress();
void setSex(string);
string getSex();
void setPoint(Point);
Point getPoint();
};
//Student.cpp
#include "Student.h"
Student::Student(){
}
void Student::setId(string ID) {
id = ID;
}
string Student::getId() {
return id;
}
void Student::setName(string NAME) {
name = NAME;
}
string Student::getName() {
return name;
}
void Student::setAddress(string ADDRESS) {
address = ADDRESS;
}
string Student::getAddress() {
return address;
}
void Student::setSex(string SEX){
sex = SEX;
}
string Student::getSex() {
return sex;
}
void Student::setPoint(Point POINT) {
point = POINT;
}
Point Student::getPoint() {
return point;
}
//Point.h
#pragma once
class Point
{
private:
string id;
float math;
float physical;
float chemistry;
float sum;
public:
Point();
~Point();
void setId(string);
string getId();
void setMath(float);
float getMath();
void setPhysical(float);
float getPhysical();
void setChemistry(float);
float getChemistry();
};
//Point.cpp
#include "Point.h"
#include<string>
using namespace std;
Point::Point(){
}
void Point::setId(string ID) {
id = ID;
}
string Point::getId(){
return id;
}
void Point::setMath(float MATH) {
math = MATH;
}
float Point::getMath() {
return math;
}
void Point::setPhysical(float PHYSICAL) {
physical = PHYSICAL;
}
float Point::getPhysical() {
return physical;
}
void Point::setChemistry(float CHEMISTRY) {
chemistry = CHEMISTRY;
}
float Point::getChemistry() {
return chemistry;
}
//Student_Controller.h
#pragma once
#include"Student.h"
#include"Point.h"
class Student_controller
{
public:
Student_controller();
~Student_controller();
void show_student();
void add_student(Student);
bool modify_student(string);
bool delete_student(string);
void sort_student(Student);
void search_student();
};
//Student_Controller.cpp
#include "Student_controller.h"
#include "Student.h"
#include "Point.h"
#include "iostream"
using namespace std;
Student_controller::Student_controller()
{
}
void Student_controller::add_student(Student st) {
}
Bây giờ em muốn viết hàm add_student() nhưng em không biết gọi thằng Student kiểu gì. mọi người có thế cho em xin demo hàm này được không ạ!
Bài liên quan