Possible Duplicate:
c++ publicly inherited class member cannot be used as default argument
Nonstatic member as a default argument of a nonstatic member function
LinkedInteger accessElement(int index, LinkedInteger *startElement=&DataArray[0]){ // Starting at *startElement*, returns the element which is at the index of *startElement+index
LinkedInteger NullElement;
if (index<0){
cout << "Index degeri sifirdan buyuk olmalidir" << endl;
NullElement.value=0;
NullElement.nextPtr=0;
return NullElement;
}
for (int i=0; i<index; i++){
if (startElement->nextPtr == NULL){ // Last elements index is null.
cout << " Erismeye calistiginiz eleman dizi sinirlarinin disindadir " << endl;
NullElement.value=0;
NullElement.nextPtr=0;
return NullElement;}
else {
startElement=startElement->nextPtr;
}
}
return *startElement;
}
This is a method in implementation of Linked Lists in c++, which simply lets access to lists elements I want to give the header as a default argument (which is indeed DataArray[0]). It fails because of the error "invalid use of non-static data member".
this->&DataArray[0]
also fails because of "this may not be used in this context" What should I do?
Also there are some issues with the context of the code. Please ignore them.