I need your help, very much. About namespace and using head file. If you
give me a partical example, I will thank you very much. Thank you,good men.
my change:
help.cpp:
////////////////////////////////////////////
#include "help.h"
#include <iostream>
#include <string>
using namespace std;
namespace Myhelp
{
void print(const string& x);
}
using namespace Myhelp;
void print(const string& x)
{
cout<<x<<endl;
}
/////////////////////////////////////////////
help.h
//////////////////////////////////////////////
//--------------------------------------------------------------------------
-
#ifndef helpH
#define helpH
namespace Myhelp
{
void print(const std::string& x);
}
//--------------------------------------------------------------------------
-
#endif
//////////////////////////////////////////////
error message

bcb 6.0)
[C++ Error] help.h(6): E2449 Size of 'print' is unknown or zero
Full parser context
help.cpp(1): #include D:\PROGRAM\WUKEXIN\FILE\help.h
help.h(5): namespace Myhelp
[C++ Error] help.h(6): E2188 Expression syntax
Full parser context
help.cpp(1): #include D:\PROGRAM\WUKEXIN\FILE\help.h
help.h(5): namespace Myhelp
[C++ Error] help.h(6): E2293 ) expected
Full parser context
help.cpp(1): #include D:\PROGRAM\WUKEXIN\FILE\help.h
help.h(5): namespace Myhelp
[C++ Error] help.cpp(7): E2238 Multiple declaration for 'print'
Full parser context
help.cpp(6): namespace Myhelp
[C++ Error] help.h(6): E2344 Earlier declaration of 'print'
Full parser context
help.cpp(6): namespace Myhelp
error message: (mingw)
In file included from list.cpp:6:
file.h:8:7: warning: no newline at end of file
H:\DOCUME~1\MAIGRE~1\LOCALS~1\Temp/cc0saaaa.o(.text+0x2e6):list.cpp:
undefined r
eference to `myfile::is_dir(std::string)'
H:\DOCUME~1\MAIGRE~1\LOCALS~1\Temp/cc0saaaa.o(.text+0x3c1):list.cpp:
undefined r
eference to `Myhelp:

rint(std::string const&)'
/////////////////////////////////////////////
"wukexin" <> 写入邮件 news:bv1usq$2n0r$...
> Help me, good men. I find mang books that introduce bit "mang header
> files",they talk too bit,in fact it is my too fool, I don't learn it, I
have
> do a test program, but I have no correct doing result in any way. Who can
> help me, I thank you very very much.
>
> list.cpp(main program)
>
//--------------------------------------------------------------------------
> -
> #pragma hdrstop
> #pragma argsused
> #include <string>
> #include <vector>
> #include <iostream>
> #include <algorithm>
> #include "help.h"
> #include "file.h"
> using namespace std;
> int main(int argc, char* argv[])
> {
> int number=argc;
> if(number<1)
> {
> cout<<"The program run program!"<<endl;
> return 0;
> }
> vector<string> option;
> for(unsigned i=1;i<argc;i++)
> {
> option.push_back(argv[i]);
> }
> sort(option.begin(),option.end());
> //for_each(option.begin()),option.end(),myhelp:
rin t);
> vector<string> filename,pathname;
> for(unsigned i=0;i<option.size();i++)
> {
> using namespace myfile;
> if( is_dir(option[i]) )
> {
> pathname.push_back(option[i]);
> }
> }
> for(unsigned i=0;i<option.size();i++)
> {
> using namespace myfile;
> print(option[i]);
> }
> return 0;
> }
>
////////////////////////////////////////////////////////////////////////////
> /
> file.h:
>
//--------------------------------------------------------------------------
> -
> #ifndef fileH
> #define fileH
> namespace myfile
> {
> using namespace std;
> bool is_dir(const string x);
> };
> #endif
>
////////////////////////////////////////////////////////////////////////////
> /
> file.cpp
>
//--------------------------------------------------------------------------
> -
> #include <dir.h>
> #ifdef fileH
> #define fileH
> #endif
> #include <string>
> using namespace std;
> bool is_dir(const string x)
> {
> struct ffblk file;
> int done=findfirst(x.c_str(),&file,FA_DIREC);
> bool result(false);
> if(0==done)
> {
> result=true;
> }
> else
> {
> result=false;
> }
> return result;
> }
>
////////////////////////////////////////////////////////////////////////////
> //
> help.h
>
//--------------------------------------------------------------------------
> -
> #ifndef helpH
> #define helpH
> namespace myhelp
> {
> void print(const string x);
> };
> #endif
>
////////////////////////////////////////////////////////////////////////////
> /
> help.cpp
>
//--------------------------------------------------------------------------
> -
> #pragma hdrstop
> #include "help.h"
> #include <string>
> #include <iostream>
> using namespace std;
> void print(const string x)
> {
> cout<<x<<endl;
> }
>
////////////////////////////////////////////////////////////////////////////
> /
> 这是编译结果:
> [C++ Error] help.h(6): E2293 ) expected
> Full parser context
> list.cpp(7): #include D:\PROGRAM\WUKEXIN\FILE\help.h
> help.h(5): namespace myhelp
> [C++ Warning] list.cpp(19): W8012 Comparing signed and unsigned values
> Full parser context
> list.cpp(11): parsing: int cdecl main(int,char * *)
> [C++ Error] list.cpp(37): E2268 Call to undefined function 'print'
> Full parser context
> list.cpp(11): parsing: int cdecl main(int,char * *)
>
>
>
>
>
>
>