How to declare this function in a class
<p>I trying to add in this function below to my class</p>

<pre><code>vector&lt;string&gt; &amp;split(const string &amp;s, char delim, vector&lt;string&gt; &amp;elems) {

    stringstream ss(s);

    string item;

    while(getline(ss, item, delim)) {

        elems.push_back(item);

    }

    return elems;

}



vector&lt;string&gt; split(const string &amp;s, char delim) {

    vector&lt;string&gt; elems;

    return split(s, delim, elems);

}
</code></pre>

<p>Below is my class file</p>

<pre><code>#ifndef LOGIN_H  
#define LOGIN_H

#include &lt;string&gt;
#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;vector&gt;
#include &lt;iostream&gt;

using namespace std;


    class Login
    {

    private:
    ifstream infile;
    string sLine,username,password;
    stringstream ss;
    int counter,logCounter;
    bool verify,end;

    public:
    Login();
    Login(string,string);
    bool loginValidate(string,string);
    };

    Login::Login()
    {

    }

    Login::Login(string user,string pass)
    {
    username=user;
    password=pass;
    }





    bool Login::loginValidate(string user,string pass)
    {
    bool result,verify;
    result=false;


    /* Begin Read account File */
    infile.open("account.txt");

    if(infile.is_open())
    {
    while (infile.good())
    {
    getline(infile, sLine);

    if(sLine!="")
    {
    //do vector split
    vector&lt;string&gt; x = split(sLine,':');




    x.clear();

    }//end if sLine


    }//end while loop
    }//end if

    infile.close();

    return result;

    }//end function loginValidate



    #endif
</code></pre>

<p>I am trying to use the split function in my loginValidate function of login - Login Class but i try declare it at above login validate and i get some errors like</p>

<pre><code> user1@ubuntu:~/yes222/New folder$ g++ test.cpp login.cpp -o main
    /tmp/ccv6uiN1.o: In function `split(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, char, std::vector&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;&amp;)':
    login.cpp:(.text+0x0): multiple definition of `split(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, char, std::vector&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::allocator&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;&amp;)'
    /tmp/ccCcz7T2.o:test.cpp:(.text+0x0): first defined here
    /tmp/ccv6uiN1.o: In function `split(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, char)':
    login.cpp:(.text+0xe9): multiple definition of `split(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, char)'
    /tmp/ccCcz7T2.o:test.cpp:(.text+0xe9): first defined here
    collect2: ld returned 1 exit status
    user1@ubuntu:~/yes222/New folder$ g++ test.cpp login.cpp -o main
    login.cpp: In member function ‘bool Login::loginValidate(std::string, std::string)’:
</code></pre>

<p><strong>Can anyone guide me . thanks!</strong></p>

<p>The function previously i just use all in a main class, but now i trying to split the login part to another class thus i got a issue with using this function in that class.. </p>
