English 中文(简体)
未明确提及当地阶层
原标题:Undefined reference to a local class
  • 时间:2010-09-15 13:04:32
  •  标签:
  • c++
  • qt
  • qjson

我刚刚在Kqjson图书馆玩.,发现“未明确提及”错误。 这是法典:

#include <qjson/qobjecthelper.h>
#include <qjson/serializer.h>

class Person: public QObject {

    Q_OBJECT

    Q_PROPERTY(QString name READ name WRITE setName)
    Q_PROPERTY(Gender gender READ gender WRITE setGender)
    Q_ENUMS(Gender)

public:
    Person(QObject *parent = 0);
    ~Person();

    QString name() const;
    void setName(const QString &name);

    enum Gender{Male, Female};
    Gender gender() const;
    void setGender(Gender gender);

private:
    QString m_name;
    Gender m_gender;

};

int main ()
{

    Person person;

    QJson::Serializer serializer;

    person.setName("Nick");
    person.setGender(Person::Male);
    QVariantMap person_map = QJson::QObjectHelper::qobject2qvariant(&person);

    QByteArray json = serializer.serialize(person_map);
    return 0;
}

因此,汇编者说,<代码>未明确提及个人:Person和等所有其他职能。 为什么?

最佳回答

仅限宣布该类方法。 您还需要define(即执行)。 目前,汇编者应如何知道<代码>Person的构造者?

问题回答

你们需要与图书馆或专栏链接,以落实个人。

如果你在“Unix”变量上拥有一个Blibqjson.a文档,你需要把——lqjson号添加到你的联系指挥线上。 如果你在视窗上用qjson重读。 平衡,你需要与qjson.lib联系。 如果你有执行文件 个人,你们需要加以汇编,并将其与你可执行的联系。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?