Note that there are some explanatory texts on larger screens.

plurals
  1. POXerces C++ SAX Parsing Problem: expected class-name before '{' token
    primarykey
    data
    text
    <p>I'm trying to run through an example given for the C++ Xerces XML library implementation. I've copied the code exactly, but I'm having trouble compiling it. </p> <pre><code>error: expected class-name before '{' token </code></pre> <p>I've looked around for a solution, and I know that this error can be caused by circular includes or not defining a class before it is used, but as you can see from the code, I only have 2 files: MySAXHandler.hpp and MySAXHandler.cpp. However, the MySAXHandler class is derived from HandlerBase, which is included.</p> <p>MyHandler.hpp</p> <pre><code>#include &lt;xercesc/sax/HandlerBase.hpp&gt; class MySAXHandler : public HandlerBase { public: void startElement(const XMLCh* const, AttributeList&amp;); void fatalError(const SAXParseException&amp;); }; </code></pre> <p>MySAXHandler.cpp</p> <pre><code>#include "MySAXHandler.hpp" #include &lt;iostream&gt; using namespace std; MySAXHandler::MySAXHandler() { } void MySAXHandler::startElement(const XMLCh* const name, AttributeList&amp; attributes) { char* message = XMLString::transcode(name); cout &lt;&lt; "I saw element: "&lt;&lt; message &lt;&lt; endl; XMLString::release(&amp;message); } void MySAXHandler::fatalError(const SAXParseException&amp; exception) { char* message = XMLString::transcode(exception.getMessage()); cout &lt;&lt; "Fatal Error: " &lt;&lt; message &lt;&lt; " at line: " &lt;&lt; exception.getLineNumber() &lt;&lt; endl; XMLString::release(&amp;message); } </code></pre> <p>I'm compiling like so:</p> <pre><code>g++ -L/usr/local/lib -lxerces-c -I/usr/local/include -c MySAXHandler.cpp </code></pre> <p>I've looked through the HandlerBase and it is defined, so I don't know why I can't derive a class from it? Do I have to override all the virtual functions in HandlerBase? I'm kinda new to C++.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload