I have a (sorta) recursive function that searches through a linked list of instances of a class. At a certain point, this recursive function will find that the instance it is called for currently is the instance that matches the search criteria. Now I'd like to know; how would I return that instance?
(very stripped down: )
Now, what goes in the place of huh?Code:class AClass { public: AClass *search(int a); AClass *next; private: int A; }; AClass *AClass::search(int a) { if (a==A) return huh; else return next->search(a); }



LinkBack URL
About LinkBacks


