Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
C++ class member declaration
I found this member declaration on a sample code, I don't understand the ";" on the parameters passed to the function.
bool DbManager::addPerson(const QString& name)
bool success = false;
// you should check if args are ok first...
query.prepare("INSERT INTO people (name) VALUES (:name)");
success = true;
qDebug() << "addPerson error: "
Which ";" do you mean?
If you mean the
nameit's to give your binding a name. It's explained here.
You could be using another name for that variable if you wanted. Using the same just makes it clearer that you are going to put a value in the name column using a binding that is also called name.
Sorry, I should have looked at my copy before I posted.
The code that i got said something like:
bool DbManager::addPerson(const QString& instring; name)
that ";" before name tripped me off. Now I cannot find the original post, or it was changed.
Does that ";" makes any sense on a function implementation?
VRonin last edited by
@Dan3460 No, that declaration is invalid in C++
It's probably a typo of some sort, but I'm feeling playful today, so I'll say it's not invalid c++. See below ;)
#define instring ) #define foo() #define name foo( bool DbManager::addPerson(const QString& instring; name)
Perfectly valid c++ :) Note that MSVC will complain because its macro expansion is fundamentally broken.
Thanks Sirs, that is what I thought.