error: cannot convert 'const std::vector<int, std::allocator<int> >' to 'int' in initialization

Hi. If anyone can help I will be eternally grateful!

I'm editing someone elses code and this throws up problems:

bool ConstraintRemover_UnderForce::hasOnlyCHneighborsConRem( int atom ) {
for ( size_t i = 0; i < nt[atom].size(); i++ )
{
int neigh = nt[atom][i];
//if ( (proteinInfo->atom(neigh).elem() != "C") && (proteinInfo->atom(neigh).elem() != "H") ) return false;
}
return true;
}

The "int neigh = nt[atom][i];" line causes the compiler to "error: cannot convert 'const std::vector<int, std::allocator<int> >' to 'int' in initialization"

In the .h file we have "const NeighborTable* nt;" declared as private so too is the above function. There exists a NeighbourTable.cpp and .h file but do not seem to be directly included in ConstraintRemover.cpp or .h. If you comment out the "int neigh = nt[atom][i];" the compiler doesn't complain about "nt[atom].size()" in the for loop.

Thanks in advance.
From what I see "nt[atom]" is a vector not a matrix "nt[atom][i]".
Practically you try to use a vector like a matrix .
@paxgs1 .essentially the probrem ts with the defination of the constraint
try this
const neibour table =[nt];
~const neibour table =[nt];
bool ConstraintRemover_UnderForce::hasOnlyCHneighborsConRem( int atom ) {
for ( size_t i = 0; i < nt[atom].size(); i++ )
{
int neigh = nt[atom][i];
//if ( (proteinInfo->atom(neigh).elem() != "C") && (proteinInfo->atom(neigh).elem() != "H") ) return false;
}
return true;
}

alternatively
if this particular parameter is not in either files and the above method is not working write a define function at the program introduction then u can call it in here
Topic archived. No new replies allowed.