Inside FileThree.h
#ifndef FILETHREE
#define FILETHREE
namespace blue{}
class Filethree
{
public:
Filethree(void);
~Filethree(void);
};
#endif
Inside FileThree.cpp
#include "Filethree.h"
#include<iostream>
using namespace std ;
namespace blue{
void blueprint(int nVar){
cout<<"red::"<<nVar<<endl;
}
}
Filethree::Filethree(void)
{
}
Filethree::~Filethree(void)
{
}
Inside FileFour.h
#ifndef FILEFOUR
#define FILEFOUR
namespace red{}
class FileFour
{
public:
FileFour(void);
~FileFour(void);
};
#endif
Inside FileFour.cpp
#include "FileFour.h"
#include<iostream>
using namespace std;
namespace red{
void redprint(double nVar){
cout<<"red::"<<nVar<<endl;
}
}
FileFour::FileFour(void)
{
}
FileFour::~FileFour(void)
{
}
Inside main.cpp
#include "FileFour.h"
#include "Filethree.h"
using namespace red ;
using namespace blue ;
int main()
{
blueprint(12);
return 0;
}
When i compile the above file it gives me the following error .
error C3861: 'blueprint': identifier not found
Can anyone tell me why i am getting this error ?
Compiler can’t find functions when they are not declared in header files.
You need to declare
blueprintfunction innamespace bluein FileThree.hFileThree.h:
Same to
redprintfunction, need to declare it in FileFour.h insidenamespace redFileFour.h