J
JBorges
I created a namespace Directory:
#include <set>
#include <string>
namespace Directory {
bool putInSet( const char *filename, std::set< std::string >
&setstrings );
}
the namespace has other functions, but they're irrelevant for now...
so, when I compile a file:
int main()
{
std::set< std::string > setstrings;
std::string filename( "anyfile" );
Directory:utInSet( filename.c_str(), setstrings );
return 0;
}
the gcc 3.3.5 ( using Linux ) shows the following error:
filesServer.cpp.text+0x192): undefined reference to
`Directory:utInSet(char const*, std::set<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::less<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > >&)'
collect2: ld returned 1 exit status
We know that string::c_str() returns a const char *. Why, in the
message error the compiler shows char const * ? Anyone can give me a
solution?
#include <set>
#include <string>
namespace Directory {
bool putInSet( const char *filename, std::set< std::string >
&setstrings );
}
the namespace has other functions, but they're irrelevant for now...
so, when I compile a file:
int main()
{
std::set< std::string > setstrings;
std::string filename( "anyfile" );
Directory:utInSet( filename.c_str(), setstrings );
return 0;
}
the gcc 3.3.5 ( using Linux ) shows the following error:
filesServer.cpp.text+0x192): undefined reference to
`Directory:utInSet(char const*, std::set<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::less<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > >&)'
collect2: ld returned 1 exit status
We know that string::c_str() returns a const char *. Why, in the
message error the compiler shows char const * ? Anyone can give me a
solution?