0

Problems using a separate class file

Hi, I was testing my learning from the c++ curso, but when I tried to make a separte class file, and run it the compiler sais that there's not such file or that the directoy is wrong. First I belived that it was I mistake so I search it, and there was no mistake. Then I belived that something was failing in the file so I created a new program and I tried again to run a separate class file, but the problem continue. So I made a post asking about this issue, but there I also didn't find a solution. Know I created a new program, and tried again to run a new class, but the problem continue. Here is the code, it is clean, because it was only created to test this class issue Main.cpp: #include <iostream> using namespace std; #include "Class.h" int main() { Class ob; } Class.h: #ifndef CLASS_H #define CLASS_H class Class { public: Class(); protected: private: }; #endif // CLASS_H Class.cpp: #include <iostream> using namespace std; #include "Class.h" Class::Class() { cout << "Hola" << endl; } I am doing it in code blocks with the GNU compiler and here is the fail message: mingw32-g++.exe -Wall -fexceptions -g -I"D:\Documentos\clases de C++\CLass Tests\" -c "D:\Documentos\clases de C++\CLass Tests\Class.cpp" -o obj\Debug\Class.o mingw32-g++.exe: error: de: No such file or directory mingw32-g++.exe: error: C++\CLass: No such file or directory mingw32-g++.exe: error: Tests\Class.cpp -o obj\Debug\Class.o: No such file or directory

7th May 2017, 6:53 PM
Luis Alfonso Alvarez
Luis Alfonso Alvarez - avatar
6 Réponses
+ 10
To import a header file, #include "Class.h" is to be used.. in main.cpp, you did it the wrong way..
5th May 2017, 4:31 AM
Meharban Singh
Meharban Singh - avatar
+ 8
Never used Code blocks, but all are your header and definition files in the same directory?
7th May 2017, 7:06 PM
Karl T.
Karl T. - avatar
+ 6
you just edited it .... lol, trying to be smart, huh?
7th May 2017, 6:08 PM
Meharban Singh
Meharban Singh - avatar
+ 4
Just follow these steps :- https://youtu.be/NTip15BHVZc
8th May 2017, 2:18 AM
Meharban Singh
Meharban Singh - avatar
+ 1
No I am not editing it to look smnarter, I am editing it to have the same code that I have in the actual program
7th May 2017, 6:49 PM
Luis Alfonso Alvarez
Luis Alfonso Alvarez - avatar
0
@Meharban how I did it wrong?
7th May 2017, 6:02 PM
Luis Alfonso Alvarez
Luis Alfonso Alvarez - avatar