程序不会编译-我做错了什么
Program Will Not Compile - What am I doing wrong?
这只是一个简单的头文件,用于使用Xerces Parser解析XML。我拼命想弄清楚这个问题,但是不管出于什么原因,编译器总是抱怨一些不应该成为问题的事情。我需要另一个人来检查一下,告诉我发生了什么事。
#include "xerces_string.h"
using namespace std;
#ifndef CHARACTER_H
#define CHARACTER_H
struct Character
{
XercesString m_Name;
public:
Character();
Character(const Character ©) : m_Name(copy.m_Name) {
};
Character(const XMLCh *wstring) : m_Name(wstring) {};
virtual ~Character() {};
};
class GraphHandler : public DefaultHandler {
XercesString m_Name;
std::vector<Character> m_List;
public:
virtual void start_document();
virtual void end_document();
virtual void start_element(
const XMLCh * const uri,
const XMLCh * const localname,
const XMLCh * const qname,
const Attributes& attributes
);
virtual void end_element(
const XMLCh * const uri,
const XMLCh * const localname,
const XMLCh * const qname
);
virtual void characters(
const XMLCh * const chars,
const unsigned int length
);
}
#endif
这是我的执行文件:
#include </usr/include/xercesc/sax2/SAX2XMLReader.hpp>
#include </usr/include/xercesc/sax2/XMLReaderFactory.hpp>
#include </usr/include/xercesc/sax2/ContentHandler.hpp>
#include </usr/include/xercesc/sax2/DefaultHandler.hpp>
#include </usr/include/xercesc/sax2/Attributes.hpp>
#include </usr/include/xercesc/util/PlatformUtils.hpp>
#include <stdio.h>
#ifdef WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#include "character.h"
#include "xerces_string.h"
int main(int argc, char* argv[])
{
//initialize the XML library
XMLPlatformUtils::Initialize();
XMLPlatformUtils::Terminate();
}
下面是我的输出:
In file included from main.cpp:15:
character.h:6: error: expected unqualified-id before ‘using’
character.h: In constructor ‘Character::Character(const XMLCh*)’:
character.h:18: error: no matching function for call to ‘XercesString::XercesString(const XMLCh*&)’
xerces_string.h:5: note: candidates are: XercesString::XercesString()
xerces_string.h:5: note: XercesString::XercesString(const XercesString&)
character.h: At global scope:
character.h:24: error: expected class-name before ‘{’ token
character.h:26: error: ISO C++ forbids declaration of ‘vector’ with no type
character.h:26: error: expected ‘;’ before ‘<’ token
character.h:37: error: ISO C++ forbids declaration of ‘Attributes’ with no type
character.h:37: error: expected ‘,’ or ‘...’ before ‘&’ token
character.h:24: error: new types may not be defined in a return type
character.h:24: note: (perhaps a semicolon is missing after the definition of ‘GraphHandler’)
main.cpp:18: error: two or more data types in declaration of ‘main’
我的xercesc目录在给定的路径中不存在。我从源代码编译了XercesC,我不知道我在做什么。我也是c++的新手。
我无法调试您的文件系统问题。然而,对我来说,对这些错误做一些翻译并不困难。
编译器说:
character.h:6: error: expected unqualified-id before ‘using’
character.h: In constructor ‘Character::Character(const XMLCh*)’:
character.h:18: error: no matching function for call to ‘XercesString::XercesString(const XMLCh*&)’
xerces_string.h:5: note: candidates are: XercesString::XercesString()
xerces_string.h:5: note: XercesString::XercesString(const XercesString&)
character.h: At global scope:
character.h:24: error: expected class-name before ‘{’ token
character.h:26: error: ISO C++ forbids declaration of ‘vector’ with no type
character.h:26: error: expected ‘;’ before ‘<’ token
character.h:37: error: ISO C++ forbids declaration of ‘Attributes’ with no type
character.h:37: error: expected ‘,’ or ‘...’ before ‘&’ token
character.h:24: error: new types may not be defined in a return type
character.h:24: note: (perhaps a semicolon is missing after the definition of ‘GraphHandler’)
main.cpp:18: error: two or more data types in declaration of ‘main’
编译器的意思是:
帮助!
当你试图使用某些东西时,我没有找到你试图使用的东西-即,我不知道任何命名空间"std"。你试过了从const XMLCh*构造XercesString,但我找不到一个可以接受它的构造函数。
您在GraphHandler定义的末尾留下了分号,所以我不知道如何理解您编写的下一个内容。
在Character结构体的函数末尾加上分号。
其他错误很可能只是没有声明正确的类型,但它们也可能是其他错误。如果你不给我看main.cpp的源代码我就不知道了。
如果你自己编译,你已经忘记了make install
命令(如果你的make文件有一个)
相关文章:
- #定义c-预处理器常量..我做错了什么
- 努力将整数转换为链表。不知道我在这里做错了什么
- .h 和.cpp文件分离时出错,但仅使用 .h 文件时没有错误.我做错了什么?
- 我的C++线程做错了什么?
- 谁能告诉我我用 getline 做错了什么 (cpp) 格式
- 没有输出的合并排序我做错了什么?
- 我正在尝试使用 while 循环从字符串中删除字母,直到没有字母。我在这里做错了什么?
- 在C++中使用 AKS 素数测试计算双胞胎素数 我做错了什么?
- 我一直试图弄清楚我在这个链表程序中做错了什么
- 我正在尝试学习如何在 c++ 中传递指针,但出现错误:没有用于调用"test"的匹配函数。我做错了什么?
- FFMPEG,C++,内存泄漏,我做错了什么?
- 我做错了什么?反向字符串 C++
- 我在这个课上做错了什么?
- 创建整数的 2D 数组,该数组将使用两个函数用随机数填充矩阵.我做错了什么?
- 在不使用内置库函数的情况下添加字符串,我做错了什么?
- 我做错了什么?GetDiskFreeSpaceExA的功能根本不起作用
- 我在查找和字符串上做错了什么?
- 我正在尝试用 c++ 制作一个日志记录框架,但信息没有传递给记录器的子组件,我做错了什么?
- 我在尝试将多个值push_back向量时出错。我做错了什么?
- 插入排序:我做错了什么?