0
C++ - external Classes - Can anyone help me to solve my Problem?
I made a C++ Program, which has an external Class like they made in the C++ Course at the Part: "more on Classes". But my Code::Blocks always output a Error with: "||=== Build: Debug in Sololearn_2 (compiler: GNU GCC Compiler) ===| C++\Sololearn_2\classnew.cpp -o obj\Debug\classnew.o||No such file or directory| ||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|" The .h and the .cpp File of the Class are in my Project directory and i don't find any Solutions for this Error. Do someone know about this Problem?
2 Réponses
- 1
do you have
#include "classnew.h"
at the top of your cpp files?
example:
main.cpp file:
#include <iostream>
#include "MyClass.h"
using namespace std;
int main() {
MyClass mc;
mc.sayHello();
}
MyClass.h file:
#ifndef _MYCLASS_H_
#define _MYCLASS_H_
void sayHello();
#endif _MYCLASS_H_
MyClass.cpp file:
#include <iostream>
#include "MyClass.h"
using namespace std;
void sayHello() {
cout << "Hello" << endl;
}