lundi 8 mars 2021

Did I write this correctly? I keep on getting errors including files. C++ 11 [closed]

        #include "user.h"
        #include <string>
        #include "teacher.h"
    
    using std::cout;
    using std::cin;
    using std::string;
    
    int main()
    {
        User user("new");
        cout << user.get_status();
        Teacher teacher;
    
        return 0;
    }
    // end of main
    
    //second file (Header file)
    
    #ifndef USER_H_INCLUDED
    #define USER_H_INCLUDED
    
    #include <iostream>
    #include <string>
    
    class User {
    
     std::string status;
    
     public:
         std::string get_status();
         User(std::string status);
    
    
    };
    
    #endif
    
    // end of second file
    
    // third file (CPP file)
    
#include "user.h"
#include <iostream>

    
    
    std::string User::get_status() {
    
     return User::status;
    
    
    };
    
    User::User(std::string status) {
    
      if(status == "new") {
    
         this->status = status;
      }
    else {
    
     this->status = "Nostatus";
    }
    
    }
      // end of third file
    // fourth file (Header)
    
    #ifndef TEACHER_H_INCLUDED
    #define TEACHER_H_INCLUDED
    
    #include <string>
    #include "user.h"
    #include <iostream>
    #include <vector>
    #include "user.cpp"
    
    class Teacher : public User {
    
    public:
        void output();
    
    
    };
    
    
    
    #endif // TEACHER_H_INCLUDED
    
    // end of fourth file
    // fifth file (Cpp)
    
    #include "teacher.h"
    #include <iostream>
    
    void Teacher::output() {
    
      std::cout << "hello world";`
    
    }

I'm having compiling errors for some reason. I'm new to stock overflow. Any help is appreciated. I use code::blocks as my IDE. I'm a beginner to C++ 11. I know that there's a ton of code here. I'm really struggling to learn this don't know why, I tried to compare the code but it happened to be the same as the tutorial video?

Aucun commentaire:

Enregistrer un commentaire