![]() |
| | #1 | |
| Registered User Join Date: Nov 2007 Location: Free Country, USA
Posts: 104
| Inlined functions as arguments Code: Player.hitper=((d10.roll-1)*10)+(d10.roll-1); The class to which the function belongs is as follows: Code: class dice
{
public:
dice(int sides);
int numsides;
int roll()
{
(rand()%numsides)+1;
}
};
Quote:
What am I doing wrong here?
__________________ Hatman Approves! | |
| DarkAlex is offline | |
| | #2 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,352
| Did you #include <cstdlib> for rand()? Of course, it looks like you should have that statement as a return statement. EDIT: Oh, but this is wrong: Code: Player.hitper=((d10.roll-1)*10)+(d10.roll-1); Code: Player.hitper=((d10.roll()-1)*10)+(d10.roll()-1);
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is offline | |
| | #3 |
| Registered User Join Date: Nov 2007 Location: Free Country, USA
Posts: 104
| Oh. That makes sense. I guess I was thinking that I was using it as an argument. Now that I'm calling the function correctly, the code complies. Thanks for your help.
__________________ Hatman Approves! |
| DarkAlex is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is it legal to have functions within functions? | Programmer_P | C++ Programming | 13 | 05-25-2009 11:21 PM |
| NULL arguments in a shell program | gregulator | C Programming | 4 | 04-15-2004 10:48 AM |
| Passing pointers between functions | heygirls_uk | C Programming | 5 | 01-09-2004 06:58 PM |
| API "Clean Up" Functions & delete Pointers :: Winsock | kuphryn | Windows Programming | 2 | 05-10-2002 06:53 PM |
| functions and pointer arguments | Unregistered | C++ Programming | 6 | 01-08-2002 05:04 PM |