const member implementation question

I have a class Pop3Adaptor with this decleration in the header file:
1
2
3
4
5
class Pop3Adaptor
{
public:
const char* User(const char* userId);
};


how would i implement it in the *.cpp file??

i tried :

const char* Pop3Adaptor::User (const char* userId)
but it doesnt compile...why?
thx!..antoher question :/...how can i initiate userId?
i tried with : cin>>userId; but it doesnt work..
Last edited on
This isn't exactly what is usually called a "const member function".

http://www.parashift.com/c++-faq/const-member-fns.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Example
{
public:

    void cmf() const; // const member function
    void mf(); // member function
};

void Example::cmf() const
{
    std::clog << "Example::cmf()" << std::endl;
}

void Example::mf()
{
    std::clog << "Example::mf()" << std::endl;
}
You probably want to initialise it in the constructor.

Take note of Catfish's post, though. Just because your function returns a const char* doesn't make it a const function.

This is probably what you want: http://ideone.com/L13CU0
Topic archived. No new replies allowed.