Jump to content

Returning something to the calling routine

CJPowell27

Hey guys I'm supposed to implement a peek function where I return the

top nodes information to the calling routing through the argument list.  I 

have to do this because I can't display to user in a member function.

my structure  is 

struct node
{
	char * name;
  	char * location;
  	char * l_name;
  	char * address;
  	int miles;
  	int price;
  	int rating;
  	node * next;
};

my peek prototype looks list list::Peek(data & found_top);

i5 4670k| Asrock H81M-ITX| EVGA Nex 650g| WD Black 500Gb| H100 with SP120s| ASUS Matrix 7970 Platinum (just sold)| Patriot Venom 1600Mhz 8Gb| Bitfenix Prodigy. Build log in progress 

Build Log here: http://linustechtips.com/main/topic/119926-yin-yang-prodigy-update-2-26-14/

Link to comment
Share on other sites

Link to post
Share on other sites

So there will be many nodes returned? What is data type? Can you change it to array (reference to pointer so you can change pointer value) so you could return array?

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Mr_KoKa said:

So there will be many nodes returned? What is data type? Can you change it to array (reference to pointer so you can change pointer value) so you could return array?

There will be one node(the top one in the queue) being returned. What do you mean what data type is it? I can't change it to an array unfortunately, it's one of the requirements

i5 4670k| Asrock H81M-ITX| EVGA Nex 650g| WD Black 500Gb| H100 with SP120s| ASUS Matrix 7970 Platinum (just sold)| Patriot Venom 1600Mhz 8Gb| Bitfenix Prodigy. Build log in progress 

Build Log here: http://linustechtips.com/main/topic/119926-yin-yang-prodigy-update-2-26-14/

Link to comment
Share on other sites

Link to post
Share on other sites

I'm asking about "data" type. list list::Peek(data & found_top); Is it class/structure that has ability to store a pointer to node?

Link to comment
Share on other sites

Link to post
Share on other sites

15 minutes ago, Mr_KoKa said:

I'm asking about "data" type. list list::Peek(data & found_top); Is it class/structure that has ability to store a pointer to node?

It is going to be a class but I'm going to the CS help department tomorrow to see the best way to organize the structures and classes tomorrow so I don't have a name for the class yet.

i5 4670k| Asrock H81M-ITX| EVGA Nex 650g| WD Black 500Gb| H100 with SP120s| ASUS Matrix 7970 Platinum (just sold)| Patriot Venom 1600Mhz 8Gb| Bitfenix Prodigy. Build log in progress 

Build Log here: http://linustechtips.com/main/topic/119926-yin-yang-prodigy-update-2-26-14/

Link to comment
Share on other sites

Link to post
Share on other sites

Ok, so you want to pass the top node you will find through argument found_top, but since you don't know how type of this argument looks like right now then all you need to know is that there has to be node pointer or long int, but node pointer would be more obvious.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×