小编Meg*_*ose的帖子

重新定义类类型 - c ++

我理解我的代码所遇到的问题,但尝试其他人建议的一些事情并不能解决我的错误.

这是我的错误消息:

In file included from proj07.driver.cpp:4:
proj07.string.cpp:10: error: redefinition of 'String::String()'
/user/cse232/Projects/project07.string.h:25: error: 'String::String()' previously defined here
proj07.string.cpp: In constructor 'String::String(const char*)':
proj07.string.cpp:19: error: expected primary-expression before 'char'
proj07.string.cpp:19: error: expected `;' before 'char'
make: *** [proj07.driver.o] Error 1
Run Code Online (Sandbox Code Playgroud)

这是我担心的那个:

proj07.string.cpp:10: error: redefinition of 'String::String()'
/user/cse232/Projects/project07.string.h:25: error: 'String::String()' previously defined here
Run Code Online (Sandbox Code Playgroud)

我知道我应该定义一次我的接口文件,但我不确定要改变什么,因为我尝试的一切都带来了更多的问题.

我的驱动程序(proj07.driver.cpp):

using namespace std;

#include <iostream>
#include "proj07.string.cpp"

int main()
{
  const char string1[] = {'a', 'b', 'c', 'd', 'e', 'f'};
  String test1();
  String test2(string1);
}
Run Code Online (Sandbox Code Playgroud)

我的支持文件(proj07.support.cpp): …

c++ class redefinition

0
推荐指数
1
解决办法
3413
查看次数

标签 统计

c++ ×1

class ×1

redefinition ×1