For homework I'm apparently supposed to implement some functions defined in <algorithm> . So this is what I have so far:

template <class I> bool m_equal( I b, I e, I b2 )                                                                                                                                                                   
{                                                                                                                                                                                                                   
    for ( ; b != e && b == b2; b++, b2++ );                                                                                                                                                                         
    return b == b2;                                                                                                                                                                                                 
}                                                                                                                                                                                                                   
template <class I, class T> I m_find( I b, I e, const T c )                                                                                                                                                         
{                                                                                                                                                                                                                   
    for ( ; b != e && *b != c; b++ );                                                                                                                                                                               
    return b;                                                                                                                                                                                                       
}                                                                                                                                                                                                                   
template <class I, class T> void m_copy( I b,I e, I d )                                                                                                                                                             
{                                                                                                                                                                                                                   
    while ( b != e ) *d++ = *b++;                                                                                                                                                                                   
}                                                                                                                                                                                                                   
template <class I, class T> void m_remove_copy_if (I b, I e, I d, T p)                                                                                                                                              
{                                                                                                                                                                                                                   
    for ( ; b != e; b++ ) if ( !p( b ) ) *d++ = *b;                                                                                                                                                                 
}

My compile command is:

cc ex0.cpp -o ex0

And the error log:

/tmp/ccvD4Xto.o: In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
ex0.cpp:(.text+0x3c): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
ex0.cpp:(.text+0x87): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
ex0.cpp:(.text+0xc5): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
ex0.cpp:(.text+0x10d): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/ccvD4Xto.o: In function `__static_initialization_and_destruction_0(int, int)':
ex0.cpp:(.text+0x157): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccvD4Xto.o: In function `__tcf_0':
ex0.cpp:(.text+0x1a4): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccvD4Xto.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

What is exactly is the problem? Thanks for help in advance.

Using a C compiler to compile C++ code.
The compiler driver will correctly invoke the correct compiler, but will fail to add on the correct libraries.

What command other than 'cc' should you use?

Oh wow, I feel stupid.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.