Good day! I am writing a simple class in C ++ when compiling I stumbled upon a strange problem like this .. I know little about C ++, but here is my .h and .cpp files:
If there are errors in the spelling of the code, I ask you to leave notes for the future like: you cannot write in C ++ like that, but you should like this
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] <<" "; } } It seems to be doing everything right, but a strange compilation error occurs ...
This is when compiling Main.cpp
And this is when compiling Student.cpp
Tell me where all my blunders?


main.cppfile is compiled, but not thestudent.cppfile. Is thestudent.cppfile actually added to the project? - Andrey Kuruljov