我创建了一个装饰类的std :: string的是,包含在项目的时候,会导致数以千计的文件,如cmath.h,cstring.h,xstring发起构建错误的许多构建错误.h和我不知道为什么。为了保持一致性,需要字符串操作的项目中的所有文件都使用此类而不是std :: string。串装饰类导致
我试图慢慢注释掉装饰类的零件要尽量使什么是实际发生的感觉,但错误才开始变得有意义,一旦整个班级被注释掉。有太多的错误一一列出,但错误的小样本包括:
Error C2733 'abs': second C linkage of overloaded function not allowed
Error C2065 'allocator': undeclared identifier
Error C2974 'std::basic_string': invalid template argument for '_Alloc'
Error C2873 'strxfrm': symbol cannot be used in a using-declaration
Error C2535 'void std::basic_string<_Elem,_Traits,_Alloc>::_Construct(_Iter,_Iter)': member function already defined or declared
有成千上万的跨越多个标准库文件中的这些错误。这是字符串装饰头文件:
#pragma once
#include <string>
#include <vector>
namespace Framework
{
class String
{
private:
std::string Data;
public:
String();
String(const char*Init);
String(int Init);
friend String operator+(String &LHS, String &RHS);
friend String operator+(String &LHS, const char *RHS);
friend String operator+(String &LHS, const char RHS);
String& operator+=(String &RHS);
String& operator+=(const char *RHS);
String& operator+=(const char RHS);
friend bool operator==(String &LHS, String &RHS);
friend bool operator==(const String &LHS, const String &RHS);
friend bool operator==(String &LHS, const char *RHS);
friend bool operator==(const String &LHS, const char *RHS);
friend bool operator!=(String &LHS, String &RHS);
friend bool operator!=(const String &LHS, const String &RHS);
friend bool operator!=(String &LHS, const char *RHS);
String& operator=(const char * RHS);
char operator[](int Index);
size_t Length();
size_t IndexOf(String SubString, size_t Offset = 0);
bool Contains(String SubString, size_t Offset = 0);
String SubString(size_t Start, size_t Count = 0);
std::vector<String> Split(char Delimeter, bool KeepEmpty = false);
const char *ToCharString();
void Insert(int Position, String Text);
void RemoveAt(int Index);
int ToInt();
double ToDouble();
bool ToBoolean();
unsigned __int8 ToByte();
};
}
是什么使这更令人费解的是,这个门面在另一个项目中完美工作,它只是因为它似乎没有这个新项目。
你张贴编译什么,我与Visual Studio,但显然你已经发布是不是一个完整的例子所以谁知道什么是在我们看不到的代码。你能编译其他东西吗? –
是的,这个项目很大且很复杂,有很多移动部件。我能够编译其他使用相同装饰类的项目。但在这种情况下,它的一个项目使用它,它不会编译。 – user1435899
如果这段代码在另一个项目中工作,那么它看起来像这个代码不是问题,其他的是。 –