Hello I have this code which works perfectly :
main.cpp :
#include <iostream>
#include "class1.hpp"
int main(){
Class1 class1;
return EXIT_SUCCESS;
}
class1.cpp
#include <iostream>
#include "class1.hpp"
Class1 :: Class1(){
class2;
}
class1.hpp
#ifndef DEF_CLASS1
#define DEF_CLASS1
#include "class2.hpp"
class Class1{
public:
Class1();
Class2 class2;
};
#endif
class2.cpp :
#include <iostream>
#include "class2.hpp"
Class2 :: Class2(){
std::cout << "Test OK1" << std::endl;
}
class2.hpp :
#ifndef DEF_CLASS2
#define DEF_CLASS2
class Class2{
public:
Class2();
};
#endif
When I compile and I execute the code I get "Test OK1" so It is okay. Right now I want to put an argument to the class 2 like this class2(std::string a)
How can I do this because I tried a lot of things without success unfortunately.
Thank you very much !
Aucun commentaire:
Enregistrer un commentaire