You forgot to specify classname in definition of newParticipant
.
Try to change it to void Messenger::newParticipant(const QString &nick)
in messenger.cpp.
Domanda
I'm totaly new in QT programming so i got a bit noob question. Why I get this error?
undefined reference to `Messenger::newParticipant(QString)'
main.cpp
#include <QCoreApplication>
#include <QTextStream>
#include "messenger.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Messenger* messenger = new Messenger();
messenger->newParticipant("AAAA");
QTextStream qout(stdout);
qout << "asd\n";
qout.flush();
return a.exec();
}
messenger.h
#ifndef MESSENGER_H
#define MESSENGER_H
#include "network/client.h"
#include <iostream>
#include <QTextStream>
class Messenger
{
public:
Messenger();
void newParticipant(const QString &nick);
private slots:
void sendMessage(const QString &message);
void participantLeft(const QString &nick);
};
#endif // MESSENGER_H
messenger.cpp
#include "messenger.h"
Messenger::Messenger()
{
QTextStream qout(stdout);
qout << "a. Constructor...\n";
qout.flush();
}
void newParticipant(const QString &nick)
{
if (nick.isEmpty())
return;
QTextStream qout(stdout);
qout << nick;
qout.flush();
}
Soluzione
You forgot to specify classname in definition of newParticipant
.
Try to change it to void Messenger::newParticipant(const QString &nick)
in messenger.cpp.
Altri suggerimenti
That's because you forgot to write Messenger::
before newParticipant
definition in your cpp file.