Добрый день! Пишу простой класс на C++ при компиляции наткнулся на вот такую вот странную проблему.. Я мало что разбираю в C++, но вот мой .h
и .cpp
файлы:
Если есть ошибки в правописании кода, прошу оставлять на будущее заметки типа: так нельзя писать в C++, а надо вот так...
Student.cpp
#include "Student.h"
#include <string>
using std::string;
Student::Student(){}
void Student::setName(string n){
name = n;
}
void Student::setSurname(string s){
surname = s;
}
void Student::setAge(int a){
age = a;
}
void Student::setCourse(int c) {
course = c;
}
void Student::setGroup(string g){
group = g;
}
void Student::setMarks(string* mark){
marks = mark;
}
string Student::getName(){
return name;
}
string Student::getSurname(){
return surname;
}
int Student::getAge(){
return age;
}
int Student::getCourse(){
return course;
}
string Student::getGroup(){
return group;
}
string* Student::getMarks(){
return marks;
}
Student.h
#ifndef Student_h
#define Student_h
#include <string>
using std::string;
class Student{
public:
Student();
void setName(string);
string getName();
void setSurname(string);
string getSurname();
void setAge(int);
int getAge();
void setCourse(int);
int getCourse();
void setGroup(string);
string getGroup();
void setMarks(string*);
string* getMarks();
private:
string name;
string surname;
int age;
int course;
string group;
string* marks;
};
#endif
Main.cpp
#include <stdio.h>
#include <iostream>
#include "Student.h"
using std::cout;
using std::endl;
int main(){
Student test;
string marks[] = {"B","B","C","A","A","A"};
test.setName("Name");
test.setSurname("Surname");
test.setAge(100);
test.setCourse(100);
test.setGroup("606.4");
test.setMarks(marks);
cout << test.getName() << endl;
cout << test.getSurname() << endl;
cout << test.getAge() << endl;
cout << test.getCourse() << endl;
cout << test.getGroup() << endl;
string* mark = test.getMarks();
for(int i = 0 ; i < 6 ; i++){
cout << mark[i] <<" ";
}
}
Вроде все правильно делаю, но странная ошибка при компиляции происходит...
Это при компиляции Main.cpp
А это при компиляции Student.cpp
Подскажите где все мои грубые ошибки?
main.cpp
, но неstudent.cpp
. Точно ли добавлен в проект файлstudent.cpp
?