Jump to content

       Hey guys, I am currently stuck at what I should be having as my function arguments.   

I don't know if it should have head/rear and whether or not they should be passed by

reference or value.  Also, I am very iffy on how I would have my program display if a

match is found becauseI am not allowed to display anything from my functions and it

is supposed to be taken care of by main. Any tips are appreciated. My main currently

has almost nothing

 

Here are my .cpp and .h files: funcions.cpp

                                                header.h

                                                main.cpp

 

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
https://linustechtips.com/topic/587804-function-arguments-help-c/
Share on other sites

Link to post
Share on other sites

Just think about it.

 

You're trying to implement a queue of some custom data-storing object. Or, hang on a second, is that a deque? I suppose it is, otherwise push() and enqueue() would do the same thing, just as their removal counterparts. You might want to rename those for the sake of clarity, since they both kinda mean the same thing (in STL a deque has push_front() and push_back() for example).

 

If you wanted to insert an object into the queue, and you had such a function, what could you possibly parse as a function argument? Hmmm...? Why, the object you want to insert itself, of course. This function also doesn't really return anything, it mainly does something, unless you want to return something like -1 in the case of an error or something similar. As for the search function, I think that one is also pretty trivial. What could you possibly be searching for?

 

 

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to post
Share on other sites

24 minutes ago, Nineshadow said:

Just think about it.

 

You're trying to implement a queue of some custom data-storing object. Or, hang on a second, is that a deque? I suppose it is, otherwise push() and enqueue() would do the same thing, just as their removal counterparts. You might want to rename those for the sake of clarity, since they both kinda mean the same thing (in STL a deque has push_front() and push_back() for example).

 

If you wanted to insert an object into the queue, and you had such a function, what could you possibly parse as a function argument? Hmmm...? Why, the object you want to insert itself, of course. This function also doesn't really return anything, it mainly does something, unless you want to return something like -1 in the case of an error or something similar. As for the search function, I think that one is also pretty trivial. What could you possibly be searching for?

 

 

The search function is going to take an input of searchName and compare it to the packages and output all of the details for the package if it finds a match.  I have both a push and enqueue function because I have to have two ADTs, one a stack and another a queue.  The stack being packages and the queue being the recipients for the packages.  Since this is the first program that I haven't been able to display from within functions I'm not sure how to return the match to main.

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 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

×