Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does Type * foo() mean/return?

I am implementing a Binary Search Tree. And it so happens one of my sources have a function written such that:

Node * BST_Insert(Node *root, int val)
{
//Body 
}

I already know that a pointer is a variable which contains the address of another variable and we can’t assign a value to a pointer, but we can assign the address of another variable to the pointer.

My Question is what the pointers on this prototype do exactly?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Node * BST_Insert(Node *root,int val) 

>Solution :

The Pointer is pointing at the address of the returned data, In this case your function returns a Node data type. For example if your function was returning an array you can declare it as Function Pointer to have access to the address of the returned array

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading