Hi Everyone i have a class Foo having a fooAddress member variable
Code in foo.h
Class Foo { String fooAddress() const; void setFooAddress(String fooAddress) .... String m_fooAddress; } Code in foo.cpp
String Foo::fooAddress() const { return m_fooAddress; } void Foo::setFooAddress(String fooAddress) { m_fooAddress = fooAddress; } Now i have a FooList Class which has a list of foos
Code in FooList.h
class FooList { editFooList(Foo foo,int index); ... private: List<Foo> m_fooArray; } Now my code in FooList.cpp is
void FooList::editFooList(Foo foo, int index) { m_fooArray.at(index).setFooAddress(foo.fooAddress()); } but i am getting the error error: C2662: 'void Foo::setFooAddress(String)' : cannot convert 'this' pointer from 'const Foo' to 'Foo &'
Since i have not defined editFooList as a const function,i am not sure why the compiler is complaining when i am trying to modify m_fooArray.Can someone please point me what i am doing wrong ?
foo::rather thanFoo::. Also I'm seeingQStringrather thanStringin places. Are you using Qt instead of the STL?List<>and alias forQList<>. QList.at() returns a const reference.