View Full Version : [C++] Error: 'not a member'
Mathiasdm
October 7th, 2007, 02:04 PM
I'm working on a small project of mine, and I'm getting an error in Eclipse:
Severity and Description Path Resource Location Creation Time Id
fout: ‘givenCompare’ is not a member of ‘Sudoku’ cppsudoku/trunk/src SudokuGrid.cxx line 56 1191749181962 13
The location of the code: http://cppsudoku.googlecode.com/svn/trunk/src/
I tried adding the 'givenCompare' as a 'friend' to SudokuGrid, but without result.
aks44
October 7th, 2007, 02:18 PM
First off, Sudoku::givenCompare does not need access to the internals of SudokuGrid. So, get rid of that useless friend declaration.
Now, how would the compiler know about Sudoku::givenCompare if you don't include the relevant header? :-\"
Mathiasdm
October 7th, 2007, 02:21 PM
I am officially an idiot :lolflag:
Mathiasdm
October 7th, 2007, 05:38 PM
Now I have another (probably stupid) question. The same line in the code (the 'sort' function) seems to have a problem:
fout: no matching function for call to ‘sort(__gnu_cxx::__normal_iterator<std::
vector<int, std::allocator<int> >*, std::vector<std::vector<int, std::allocator<int>
>, std::allocator<std::vector<int, std::allocator<int> > > > >, __gnu_cxx::
__normal_iterator<std::vector<int, std::allocator<int> >*, std::vector<std::
vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::
allocator<int> > > > >, <unresolved overloaded function type>)’
If I'm interpreting this correctly, Eclipse seems to think there's no such thing as a sort function with 3 arguments :confused::confused:
Edit: If you happen to have any other suggestions to improve my code, please do mention :-)
aks44
October 7th, 2007, 06:09 PM
Eclipse seems to think there's no such thing as a sort function with 3 arguments :confused::confused:
I strongly suggest you to use a compiler/environment with more descriptive error messages... (or to copy full error ouput when posting) ;)
eg. G++ tells me:invalid initialization of reference of type «std::vector<int, std::allocator<int> >&" from expression of type «const std::vector<int, std::allocator<int> >"
I'm pretty sure you can figure it out with this information. ;)
If you happen to have any other suggestions to improve my code, please do mention
Make your code const-correct? :p
Mathiasdm
October 9th, 2007, 04:12 AM
Thanks, I managed to fix it :) The error was in the HelperFunctions class.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.