-1
a* b::find() const
{
  a* pointr = head;

  return pointr;

}

This is my code but visual studio is underlining pointr in the return pointr line? What's wrong with my code?

EDIT: SORRY TYPO

user782311
  • 911
  • 2
  • 9
  • 9
  • Explain what you are trying to do and show more code. Right now it is unclear. If Als answer solved your problem accept his answer. – Begemoth Jan 31 '12 at 11:51
  • It would be much easier if you show us the actual error message VS gives you. – Fiktik Jan 31 '12 at 11:51
  • is there an actual warning message from the IDE? – araqnid Jan 31 '12 at 11:52
  • Probably one of those stupid spell-check features they put in which is stupid as there is nothing in the C++ standard that say you have to use correctly spelt English words, although meaningful identifiers are always advantageous, of course. – CashCow Jan 31 '12 at 12:34

2 Answers2

3
a* pointer = head;

return pointr;   

You d not have any variable declared as pointr in the scope of the function, How will the compiler know unless you declare it?

pointr and pointer are not same, there is an e missing.

Assuming that is a typo,
Your function returns a pointer but what it points to is important in this case. If head is a local variable or pointer without dynamic memory allocation(pointing to local object) then your pointer pointer is pointing to a local object, which will be destroyed once the function returns and will be a dangling pointer.

Remember the Rule:
You should not return reference or pointer to an variable local to function.

Alok Save
  • 202,538
  • 53
  • 430
  • 533
1

You have a wrong variable returned

return pointr;

in your code. It is not defined in the scope.

shiraz
  • 1,208
  • 2
  • 12
  • 26