Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

c++ - request for member 'testLogin' in 'k', whitch is pointer type 'Konto*'

Hello I am learning c++ right now but I dont find an answer to my error.

The Problem is k.testLogin(); and produces the Error: [Error] request for member 'testLogin' in 'k', which is of pointer type 'Konto*' (maybe you meant to use '->' ?)

The function testLogin() from Konto looks like this and is public:
void testLogin()
        {
            (empty right now because doesnt work)
        }

Konstruktor of Konto:

Konto(char response)
    {
        switch(response)
            {   
                case ('1'): neuesKonto(); cout<<"
Konto wurde erstellt!";break;
                case ('2'): logIn();break;
                default: cout<<"
Falsche Eingabe!";break;
            }
    }

this is my main:

Konto* k;
bool loggedIn;
int main() {
    srand(0);
    do
    {
        cout <<"Bankkonten verwalten und erstellen...
";
    cout <<"--- 1 = neuesKonto --- 2 = LOG-IN --- 
";  
    cout <<"Eingabe: "; 
    char response;
    std::cin >> response;
    k = new Konto(response);
    k.testLogin();

    }while(loggedIn == true);

    return 0;
}

Everything works I only cant run k.testLogin(); ...

Thank you for help... Konto.h is kinda big so I dont post it here if not needed.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

How about reading your own error message?

maybe you meant to use '->' ?

k->testLogin() would be the correct way in your case.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...