English 中文(简体)
Xerces C++ SAX 包装问题:在{前的预计类别名称
原标题:Xerces C++ SAX Parsing Problem: expected class-name before { token

I m试图通过为C++树立榜样 Xerces XML 图书馆的实施。 我完全照搬了该法典,但我很麻烦地汇编该守则。

error: expected class-name before  {  token

我探讨了解决办法,我知道,这一错误可能是循环造成的,包括或不在使用之前确定一个类别,但正如你从法典中看到的那样,我只有2个档案: MySAXHandler.hpp和MySAXHandler.cpp。 然而,MySAXHandler的班子来自HandlerBase,其中包括。

MyHandler.hpp

#include <xercesc/sax/HandlerBase.hpp>

class MySAXHandler : public HandlerBase {
public:
    void startElement(const XMLCh* const, AttributeList&);
    void fatalError(const SAXParseException&);
};

MySAXHandler.cpp

#include "MySAXHandler.hpp"
#include <iostream>

using namespace std;

MySAXHandler::MySAXHandler()
{
}

void MySAXHandler::startElement(const XMLCh* const name,
                       AttributeList& attributes)
{
    char* message = XMLString::transcode(name);
    cout << "I saw element: "<< message << endl;
    XMLString::release(&message);
}

void MySAXHandler::fatalError(const SAXParseException& exception)
{
    char* message = XMLString::transcode(exception.getMessage());
    cout << "Fatal Error: " << message
         << " at line: " << exception.getLineNumber()
         << endl;
    XMLString::release(&message);
}

我这样汇编:

g++ -L/usr/local/lib -lxerces-c -I/usr/local/include -c MySAXHandler.cpp 

我先看手脚,然后加以界定,因此我不知道我为什么不能从中得出一个等级? 我是否必须超越手勒巴斯的所有虚拟职能? 对C++的新字。

提前感谢。

最佳回答

添加<代码>使用名称空间xercesc;或明确指明Xerces类别的名称空间(例如xercesc:HandlerBase)。

Edit: 还有<代码>XERCES_CPP_NAMESPACE_USE 宏观,该代码应等同于使用说明。

问题回答

暂无回答




相关问题
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?

热门标签