Friday, November 16, 2012

algorithm – How can I refer to what called a function in C++?

I was wondering if there is a way in C++ to know what called a function? Like the this keyword in Java or JavaScript.


For example, I have a function called insert, which inserts an item into a linked list, I want the linked-list that called those the function insert to call two other functions. How would I do that?


I have this right now, is this valid?



bool linked_list::insert( int i )
{
bool inserted = false;

if( this.is_present(i) ) /* function is_present is defined earlier checks if an int is already in the linked-list. */
{
inserted = true // already inside the linked-list
}
else
{
this.Put( 0, i ); /* function Put is defined earlier and puts an int in a linked-list at a given position (first param.). */
inserted = true; // it was put it.

}
return inserted;
}






Rating: 1 out of 5 based on 3 ratings



The post algorithm – How can I refer to what called a function in C++? appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/algorithm-how-can-i-refer-to-what-called-a-function-in-c.html

No comments:

Post a Comment