Here is Libaray 1 that I would like in the namespace "MyLib"
/**
* lib1.h
*/
#ifndef LIB1_H
#define LIB1_H
#include <iostream>
#include <fstream>
#include <vector>
namespace MyLib {
class Lib1;
}
class Lib1 {
public:
Lib1();
~Lib1();
int some_lib1_function(int foo);
private:
MyLib::Lib1 *lib1;
};
#endif
/**
* lib1.cpp
*/
#include "lib1.h"
using namespace std;
Lib1::Lib1() : lib1(new MyLib::Lib1)
{
}
Lib1::~Lib1()
{
}
int Lib1::some_lib1_function(int foo)
{
// do stuff with foo
return foo;
}
Now here is Libaray 2 that I would like also like in namespace, however I want this lib to be able to access functions in the first lib, from within functions. See below.
/**
* lib2.h
*/
#ifndef LIB2_H
#define LIB2_H
#include <iostream>
#include <fstream>
#include <vector>
namespace MyLib {
class Lib2;
}
class Lib2 {
public:
Lib2();
~Lib2();
int some_lib2_function(int foo);
private:
MyLib::Lib2 *lib2;
};
#endif
/**
* lib2.cpp
*/
#include "lib2.h"
using namespace std;
Lib2::Lib2() : lib2(new MyLib::Lib2)
{
}
Lib2::~Lib2()
{
}
int Lib2::some_lib2_function(int foo)
{
// do stuff with foo
// using function from Lib1 within this Lib2
return Fallout::lib1->some_lib1_function(foo);
}
How could I go about doing this, the above is obvious not going to work as its just an example i tapped up for this post.
Thanks.