我正在尝试将矢量用作成员变量。
GameOfLife.h
class GameOfLifeManager {
std::vector<Cell::Cell> cells;
...
GameOfLife.cpp
...
cells.push_back(Cell::Cell(x,y,false));
...
和Cells.h看起来像这样
#ifndef CELL_H_
#define CELL_H_
namespace Cell {
class Cell {
bool alive;
int posX;
int posY;
Cell* left;
Cell* right;
Cell* top;
Cell* bottom;
Cell* topLeft;
Cell* topRight;
Cell* bottomRight;
Cell* bottomLeft;
public:
Cell(int x, int y, bool alive);
int CountNeighbours();
void Kill();
void Resurrect();
};
} /* namespace Zell */
#endif /* CELL_H_ */
如果我试着打电话cells.push_back(Cell::Cell(x,y,false))
eclipse告诉我“从这里需要”
我也无法解密错误消息。任何想法出了什么问题?
Description Resource Path Location Type ‘::fwprintf’ has not been declared GameOfLife line 149, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::fwscanf’ has not been declared GameOfLife line 150, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::getwc’ has not been declared GameOfLife line 151, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::getwchar’ has not been declared GameOfLife line 152, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::fgetws’ has not been declared GameOfLife line 145, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::fputwc’ has not been declared GameOfLife line 146, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::fputws’ has not been declared GameOfLife line 147, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::fwide’ has not been declared GameOfLife line 148, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::mbstate_t’ has not been declared GameOfLife line 66, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wint_t’ has not been declared GameOfLife line 141, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::btowc’ has not been declared GameOfLife line 143, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::fgetwc’ has not been declared GameOfLife line 144, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘void GameOfLifeManager::operator delete [](void*)’ may not be declared within a namespace GameOfLife line 100, external location: /usr/include/c++/4.7/new C/C++ Problem ‘void* GameOfLifeManager::operator new(GameOfLifeManager::std::size_t, const GameOfLifeManager::std::nothrow_t&)’ may not be declared within a namespace GameOfLife line 102, external location: /usr/include/c++/4.7/new C/C++ Problem ‘void* GameOfLifeManager::operator new [](GameOfLifeManager::std::size_t, const GameOfLifeManager::std::nothrow_t&)’ may not be declared within a namespace GameOfLife line 104, external location: /usr/include/c++/4.7/new C/C++ Problem ‘void GameOfLifeManager::operator delete(void*, const GameOfLifeManager::std::nothrow_t&)’ may not be declared within a namespace GameOfLife line 106, external location: /usr/include/c++/4.7/new C/C++ Problem ‘void GameOfLifeManager::operator delete [](void*, const GameOfLifeManager::std::nothrow_t&)’ may not be declared within a namespace GameOfLife line 108, external location: /usr/include/c++/4.7/new C/C++ Problem ‘void* GameOfLifeManager::operator new(GameOfLifeManager::std::size_t, void*)’ may not be declared within a namespace GameOfLife line 111, external location: /usr/include/c++/4.7/new C/C++ Problem ‘void* GameOfLifeManager::operator new [](GameOfLifeManager::std::size_t, void*)’ may not be declared within a namespace GameOfLife line 113, external location: /usr/include/c++/4.7/new C/C++ Problem required from here GameOfLifeManager.cpp /GameOfLife/src line 27 C/C++ Problem ‘void GameOfLifeManager::operator delete(void*, void*)’ may not be declared within a namespace GameOfLife line 117, external location: /usr/include/c++/4.7/new C/C++ Problem ‘::wcstoull’ has not been declared GameOfLife line 260, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::__gnu_cxx’ has not been declared GameOfLife line 266, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::__gnu_cxx’ has not been declared GameOfLife line 267, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::__gnu_cxx’ has not been declared GameOfLife line 268, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘mbstate_t’ in namespace ‘GameOfLifeManager::std’ does not name a type GameOfLife line 65, external location: /usr/include/c++/4.7/bits/char_traits.h C/C++ Problem ‘void* GameOfLifeManager::operator new(GameOfLifeManager::std::size_t)’ may not be declared within a namespace GameOfLife line 94, external location: /usr/include/c++/4.7/new C/C++ Problem ‘void* GameOfLifeManager::operator new [](GameOfLifeManager::std::size_t)’ may not be declared within a namespace GameOfLife line 96, external location: /usr/include/c++/4.7/new C/C++ Problem ‘void GameOfLifeManager::operator delete(void*)’ may not be declared within a namespace GameOfLife line 98, external location: /usr/include/c++/4.7/new C/C++ Problem ‘::wcschr’ has not been declared GameOfLife line 206, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wscanf’ has not been declared GameOfLife line 205, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcsrchr’ has not been declared GameOfLife line 208, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcspbrk’ has not been declared GameOfLife line 207, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wmemchr’ has not been declared GameOfLife line 210, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcsstr’ has not been declared GameOfLife line 209, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcstoll’ has not been declared GameOfLife line 259, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcstold’ has not been declared GameOfLife line 250, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcsxfrm’ has not been declared GameOfLife line 198, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcstoul’ has not been declared GameOfLife line 197, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wmemcmp’ has not been declared GameOfLife line 200, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wctob’ has not been declared GameOfLife line 199, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wmemmove’ has not been declared GameOfLife line 202, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wmemcpy’ has not been declared GameOfLife line 201, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wprintf’ has not been declared GameOfLife line 204, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wmemset’ has not been declared GameOfLife line 203, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcsrtombs’ has not been declared GameOfLife line 189, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcsspn’ has not been declared GameOfLife line 190, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcsncmp’ has not been declared GameOfLife line 187, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcsncpy’ has not been declared GameOfLife line 188, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcstok’ has not been declared GameOfLife line 195, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcstol’ has not been declared GameOfLife line 196, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcstod’ has not been declared GameOfLife line 191, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcstof’ has not been declared GameOfLife line 193, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcscoll’ has not been declared GameOfLife line 181, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcscpy’ has not been declared GameOfLife line 182, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcscat’ has not been declared GameOfLife line 179, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcscmp’ has not been declared GameOfLife line 180, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcslen’ has not been declared GameOfLife line 185, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcsncat’ has not been declared GameOfLife line 186, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcscspn’ has not been declared GameOfLife line 183, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcsftime’ has not been declared GameOfLife line 184, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::vswprintf’ has not been declared GameOfLife line 169, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::vfwscanf’ has not been declared GameOfLife line 166, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::vfwprintf’ has not been declared GameOfLife line 164, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::ungetwc’ has not been declared GameOfLife line 163, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::wcrtomb’ has not been declared GameOfLife line 178, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::vwscanf’ has not been declared GameOfLife line 176, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::vwprintf’ has not been declared GameOfLife line 174, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::vswscanf’ has not been declared GameOfLife line 172, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::mbsrtowcs’ has not been declared GameOfLife line 156, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::mbsinit’ has not been declared GameOfLife line 155, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::mbrtowc’ has not been declared GameOfLife line 154, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::mbrlen’ has not been declared GameOfLife line 153, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::swscanf’ has not been declared GameOfLife line 162, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::swprintf’ has not been declared GameOfLife line 160, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::putwchar’ has not been declared GameOfLife line 158, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘::putwc’ has not been declared GameOfLife line 157, external location: /usr/include/c++/4.7/cwchar C/C++ Problem ‘void GameOfLifeManager::operator delete [](void*, void*)’ may not be declared within a namespace GameOfLife line 118, external location: /usr/include/c++/4.7/new C/C++ Problem ‘::lconv’ has not been declared GameOfLife line 55, external location: /usr/include/c++/4.7/clocale C/C++ Problem ‘::setlocale’ has not been declared GameOfLife line 56, external location: /usr/include/c++/4.7/clocale C/C++ Problem ‘::localeconv’ has not been declared GameOfLife line 57, external location: /usr/include/c++/4.7/clocale C/C++ Problem ‘::isalnum’ has not been declared GameOfLife line 66, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::isalpha’ has not been declared GameOfLife line 67, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::iscntrl’ has not been declared GameOfLife line 68, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::isdigit’ has not been declared GameOfLife line 69, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::isgraph’ has not been declared GameOfLife line 70, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::islower’ has not been declared GameOfLife line 71, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::isprint’ has not been declared GameOfLife line 72, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::ispunct’ has not been declared GameOfLife line 73, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::isspace’ has not been declared GameOfLife line 74, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::isupper’ has not been declared GameOfLife line 75, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::isxdigit’ has not been declared GameOfLife line 76, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::tolower’ has not been declared GameOfLife line 77, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::wctrans_t’ has not been declared GameOfLife line 84, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::toupper’ has not been declared GameOfLife line 78, external location: /usr/include/c++/4.7/cctype C/C++ Problem ‘::wint_t’ has not been declared GameOfLife line 86, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::wctype_t’ has not been declared GameOfLife line 85, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswalpha’ has not been declared GameOfLife line 89, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswalnum’ has not been declared GameOfLife line 88, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswcntrl’ has not been declared GameOfLife line 93, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswblank’ has not been declared GameOfLife line 91, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswdigit’ has not been declared GameOfLife line 95, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswctype’ has not been declared GameOfLife line 94, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswlower’ has not been declared GameOfLife line 97, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswgraph’ has not been declared GameOfLife line 96, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswpunct’ has not been declared GameOfLife line 99, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswprint’ has not been declared GameOfLife line 98, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswupper’ has not been declared GameOfLife line 101, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswspace’ has not been declared GameOfLife line 100, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::towlower’ has not been declared GameOfLife line 104, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::towupper’ has not been declared GameOfLife line 105, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::iswxdigit’ has not been declared GameOfLife line 102, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::towctrans’ has not been declared GameOfLife line 103, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::wctrans’ has not been declared GameOfLife line 106, external location: /usr/include/c++/4.7/cwctype C/C++ Problem ‘::wctype’ has not been declared GameOfLife line 107, external location: /usr/include/c++/4.7/cwctype C/C++ Problem no matching function for call to ‘operator new(sizetype, void*)’ GameOfLife line 120, external location: /usr/include/c++/4.7/ext/new_allocator.h C/C++ Problem required from ‘static void GameOfLifeManager::__gnu_cxx::__alloc_traits<_Alloc>::construct(_Alloc&, GameOfLifeManager::__gnu_cxx::__alloc_traits<_Alloc>::pointer, const
_Tp&) [with _Tp = GameOfLifeManager::Cell::Cell; _Alloc = GameOfLifeManager::std::allocator<GameOfLifeManager::Cell::Cell>; GameOfLifeManager::__gnu_cxx::__alloc_traits<_Alloc>::pointer = GameOfLifeManager::Cell::Cell*]’ GameOfLife line 202, external location: /usr/include/c++/4.7/ext/alloc_traits.h C/C++ Problem required from ‘void GameOfLifeManager::std::vector<_Tp,
_Alloc>::push_back(const value_type&) [with _Tp = GameOfLifeManager::Cell::Cell; _Alloc = GameOfLifeManager::std::allocator<GameOfLifeManager::Cell::Cell>; GameOfLifeManager::std::vector<_Tp, _Alloc>::value_type = GameOfLifeManager::Cell::Cell]’ GameOfLife line 885, external location: /usr/include/c++/4.7/bits/stl_vector.h C/C++ Problem required from ‘static _ForwardIterator GameOfLifeManager::std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = GameOfLifeManager::Cell::Cell*; _ForwardIterator = GameOfLifeManager::Cell::Cell*; bool _TrivialValueTypes = false]’ GameOfLife line 77, external location: /usr/include/c++/4.7/bits/stl_uninitialized.h C/C++ Problem required from ‘void GameOfLifeManager::std::vector<_Tp,
_Alloc>::_M_insert_aux(GameOfLifeManager::std::vector<_Tp, _Alloc>::iterator, const _Tp&) [with _Tp = GameOfLifeManager::Cell::Cell; _Alloc = GameOfLifeManager::std::allocator<GameOfLifeManager::Cell::Cell>; GameOfLifeManager::std::vector<_Tp, _Alloc>::iterator = GameOfLifeManager::__gnu_cxx::__normal_iterator<GameOfLifeManager::Cell::Cell*, GameOfLifeManager::std::vector<GameOfLifeManager::Cell::Cell> >; typename GameOfLifeManager::std::_Vector_base<_Tp, _Alloc>::pointer = GameOfLifeManager::Cell::Cell*]’ GameOfLife line 360, external location: /usr/include/c++/4.7/bits/vector.tcc C/C++ Problem required from ‘_ForwardIterator GameOfLifeManager::std::__uninitialized_move_if_noexcept_a(_InputIterator,
_InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = GameOfLifeManager::Cell::Cell*; _ForwardIterator = GameOfLifeManager::Cell::Cell*; _Allocator = GameOfLifeManager::std::allocator<GameOfLifeManager::Cell::Cell>]’ GameOfLife line 283, external location: /usr/include/c++/4.7/bits/stl_uninitialized.h C/C++ Problem required from ‘_ForwardIterator GameOfLifeManager::std::__uninitialized_copy_a(_InputIterator,
_InputIterator, _ForwardIterator, GameOfLifeManager::std::allocator<_Tp>&) [with _InputIterator = GameOfLifeManager::Cell::Cell*; _ForwardIterator = GameOfLifeManager::Cell::Cell*; _Tp = GameOfLifeManager::Cell::Cell]’ GameOfLife line 260, external location: /usr/include/c++/4.7/bits/stl_uninitialized.h C/C++ Problem required from ‘_ForwardIterator GameOfLifeManager::std::uninitialized_copy(_InputIterator,
_InputIterator, _ForwardIterator) [with _InputIterator = GameOfLifeManager::Cell::Cell*; _ForwardIterator = GameOfLifeManager::Cell::Cell*]’ GameOfLife line 119, external location: /usr/include/c++/4.7/bits/stl_uninitialized.h C/C++ Problem no matching function for call to ‘operator new(sizetype, void*)’ GameOfLife line 85, external location: /usr/include/c++/4.7/bits/stl_construct.h C/C++ Problem required from ‘void GameOfLifeManager::std::vector<_Tp,
_Alloc>::push_back(const value_type&) [with _Tp = GameOfLifeManager::Cell::Cell; _Alloc = GameOfLifeManager::std::allocator<GameOfLifeManager::Cell::Cell>; GameOfLifeManager::std::vector<_Tp, _Alloc>::value_type = GameOfLifeManager::Cell::Cell]’ GameOfLife line 893, external location: /usr/include/c++/4.7/bits/stl_vector.h C/C++ Problem make:
*** [src/GameOfLifeManager.o] Error 1 GameOfLife C/C++ Problem
答案 0 :(得分:1)
看起来您在命名空间内有#include
个语句。
不在您显示的代码中......可能在您的源文件中。