Hello Phil.
27 Mar 98 17:27, Phil Ohl wrote to All:
PO> I am having a minor problem getting pointers to work correctly for me. I
PO> have made A pointer something like.
PO> void admin::raise(employee *luckyperson)
PO> {
PO> luckyperson->salary *= 1.75;
PO> }
PO> and I call the function in main.
PO> admin1 raise(employee1);
PO> this code however does not seem to work. Help!
It would have helped if you had given more info about the data.
you have a class named admin which contains a method names raise,
correct?
What I'm not clear about it the object employee. What is it?
It would make more sense to me if you did something like this...
class employee
{
public:
void display_emp_data( void );
int raise( double * );
// ...
private:
char name[37];
double salary;
};
int employee::raise( double * salary_mod )
{
if( salary + salary_mod <= MAX_SALARY )
{
salary += salary_mod;
return 0;
}
else
return -1;
}
// this is really contrived and besides, there is no really good
// reason to use pointers since C++ has reference variables.
//
int main( void )
{
employee corporation_slave;
double increase;
increase = 2176.3934;
if( corporation_slave.raise( &increase ) == 1 )
// do something, this slave is makin' too much!
// ...
PO> Thank You in advance.
Thank you that is easy enough for even me to comment on. I'm
pretty green with C++ too. :^)
-Roger
--- Msged/386 4.20 beta 3kl3
(1:273/404@fidonet)
---------------
* Origin: Box Of Rotting Corpses BBS, Upper Darby, PA, USA
|