473,511 Members | 14,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Vending Machine - Header files and Member Function Definitions

23 New Member
Here's the deal:

I've been working on this little program forever now, and can't seem to get the final little glitches out of it.

I am to build a vending machine, using 2 header .h files (one for the cash register and the other for the dispenser), and 2 member function definitions .cpp (one for each).

It is a little lengthy, and there are 5 files so I uploaded them to my webspace. If anyone could take a look at my code and possibly fix it and make it work fully before I do, that'd be really great! Any help asap would be greatly appreciated!

I've included the URL to the files at the bottom of this post. If anyone happens to get this before me, feel free to email me with the files.

Thanks to you all in advance!

-------------------------------------------------------------------------------------------------------------------

URL: http://home.cogeco.ca/~iscooze/vendingMachine/
Mar 5 '07 #1
9 3991
horace1
1,510 Recognized Expert Top Contributor
the only major problem I can see is you have a ; missing from the end of DISPENSER.H which would generate errors with you compile DISPENSER.cpp
Expand|Select|Wrap|Line Numbers
  1. } // end class DISPENSER
it should be
Expand|Select|Wrap|Line Numbers
  1. }; // end class DISPENSER
what other problem do you have?
Mar 5 '07 #2
vpascuzzi
23 New Member
the only major problem I can see is you have a ; missing from the end of DISPENSER.H which would generate errors with you compile DISPENSER.cpp
Expand|Select|Wrap|Line Numbers
  1. } // end class DISPENSER
it should be
Expand|Select|Wrap|Line Numbers
  1. }; // end class DISPENSER
what other problem do you have?
Compile errors in defining new definitions in the default constructor. It's just been very tedious.

Did you try to compile it yourself? I cannot get the driver to work with the classes. For example, making objects to use.
Mar 5 '07 #3
vpascuzzi
23 New Member
Actually, adding in the ' ; ' made it compile! :)

Now, if you have any help on maing the program run and come together, it'd be greatly appreciated!


Thanks!
Mar 5 '07 #4
horace1
1,510 Recognized Expert Top Contributor
Actually, adding in the ' ; ' made it compile! :)

Now, if you have any help on maing the program run and come together, it'd be greatly appreciated!


Thanks!
this compiled and ran OK
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <conio.h>
  3. using namespace std;
  4.  
  5. #include "DISPENSER.h"
  6. #include "CASHREGISTER.h"
  7.  
  8. int main( )
  9.     CASHREGISTER cash(500);
  10.     DISPENSER disp;
  11.     cash.currentBalance();
  12.     system("pause");
  13.     }; // end main
  14.  
from this you can build up a program testing each function in turn
Mar 5 '07 #5
vpascuzzi
23 New Member
I tried compiling that code into the main, but it does not work. I tried both Borland 5 and Dev C++.

I get an error in Dev like this:

Makefile.win
$(BIN): $(OBJ)

Multiple target patterns. Stop.

I don't know what the problem is! It is driving me mad! I don't know how the project does not compile.

I just want to test the displayMessage( ) function, to get a starting point on running and debugging the functions one at a time.

Any ideas?
Mar 5 '07 #6
vpascuzzi
23 New Member
I guess you can disregard my last post, just because I tend to be a bonehead when it comes to the simplest things.

The reason I was getting the compiler error was because I did not have all of my files saved in the same directory. They were in a different dir than my project file, causing this error.

Anyways, I think I can handle it from here, and thanks for the help earlier. I'll keep you up to date on my progress!

I tried compiling that code into the main, but it does not work. I tried both Borland 5 and Dev C++.

I get an error in Dev like this:

Makefile.win
$(BIN): $(OBJ)

Multiple target patterns. Stop.

I don't know what the problem is! It is driving me mad! I don't know how the project does not compile.

I just want to test the displayMessage( ) function, to get a starting point on running and debugging the functions one at a time.

Any ideas?
Mar 5 '07 #7
vpascuzzi
23 New Member
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <conio.h>
  3. using namespace std;
  4.  
  5. #include "DISPENSER.h"
  6. #include "CASHREGISTER.h"
  7.  
  8. int main( )
  9. {
  10.  
  11.     DISPENSER disp;
  12.     CASHREGISTER cash( 500 );
  13.  
  14.     disp.userOption( int userAnswer );
  15.  
  16.     return 0;
  17.  
  18. }; // end main
14 C:\Documents and Settings\vpascuzzi\My Documents\School\VENDINGMACHINE_DRIVER.cpp expected primary-expression before "int"

This won't run. I'm not 100% sure on the syntax of creating an object and using the functions.

Any suggestions?
Mar 5 '07 #8
vpascuzzi
23 New Member
Ok, for the most part I have this thing working. I know my driver .cpp is screwy because depending on what options I choose, I sometimes I have to input the same answer twice.

If someone could take a look at it from:

http://home.cogeco.ca/~iscooze

It's mostly in the driver that things aren't going smoothly. My values are all assigned to '0'.

Any help would be appreciated.


Thanks!
Mar 6 '07 #9
vpascuzzi
23 New Member
Hooray!!!

After a few more hours of hard work and debugging, my program finally works properly and is stable! Just wanted to give a big thanks to horace1 and anybody else who at least read my post.

I'll be around for a while, so if any of you have any questions, I'll be sure to give any advice I can!

Thanks thescripts.com!

----------------------------------

URL of completed vending machine: Vending Machine Solution and Executable
Mar 6 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
5111
by: dharmesh Gupta | last post by:
Hi All, i am new to header files , and have a basic question , i have made my program in three files namely, idr_bpl.cpp( contains class definitions and function definitions) bpl.cpp(...
31
2748
by: Steven T. Hatton | last post by:
If a header is not necessarily a source file, and the sequences delimited by < and > in header names aren't necessarily valid source file names, what exactly is a header? -- p->m == (*p).m == p.m...
11
5549
by: ambika | last post by:
Iam just trying to know "c". And I have a small doubt about these header files. The header files just contain the declaration part...Where is the definition for these declarations written??And how...
3
1751
by: bill | last post by:
I firmly believe that it is always a bad idea to put code in a header file. Nothing pisses me off more than seeing function definitions in a ..h, and I recently was truly blessed :) to witness...
18
3559
by: Al | last post by:
I'm still trying to do this but it never worked! In a .cpp file, I write the code, and at the beginning, I write: #ifndef MYLIST_H #define MYLIST_H ....to end: #endif What's wrong with it for...
4
1850
by: Generic Usenet Account | last post by:
In our environment we have several C++ header files that have some inline member function definitions. For some reason, I am unable to step through the source code of those member functions in my...
0
6023
by: joestevens232 | last post by:
I am seriously stuck and have been working on this for hours and hours and can't figure out my next step....heres the program assignment. This vending machine dispenses 1. M&Ms ($.65), 2. Chips...
36
3786
by: zouyongbin | last post by:
Stanley B Lippman in his "C++ Primer" that a definition like this should not appear in a header file: int ix; The inclusion of any of these definitions in two or more files of the same...
7
2161
by: ben | last post by:
Hi, I have few doubts about header files. Is it true that header files always have only "function declaration" and not definition? Next where can i find definition of functions defined in...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7349
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5659
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.