Click to See Complete Forum and Search --> : C++ Question


Gweedo
02-07-2001, 12:42 PM
Can you do the following?

Function1 :: Dude()
{
..
...
.....
}

Fuction2 :: WhatDude()
{
make a call to Function1 :: Dude()
..
...
....
}

If so how would you call the function correctly? Also, do I break any standards by doing this if it is legal? I know how to handle differently but it would seem faster the above way if possible.

Thanks. :)

kmj
02-07-2001, 01:23 PM
Do you mean Class1::Dude and Class2::Dude ?

I don't think what you wrote (Function1::Dude and Function2::DUde) makes any sense if Function1 and Function2 are functions. If they are names of classes, then sure, you can do it, as long as the function being called from within the other function is public. To do it, you have to have an object of that class instantiated first. If you had an object of Class1, called Object1, you could call the function with "Object1.Dude();"; unless the function were declared static which means that the function exists for the class, not for each object. You would call a static function with "Class1::Dude();";

[ 07 February 2001: Message edited by: kmj ]

f'lar
02-07-2001, 03:09 PM
class Function1
{
public:
void Dude()
{
//do something
}
};

class Function2
{
public:
void WhatDude()
{
Function1 object1;
object1.Dude();
}
};


or


class Function1
{
public:
static void Dude()
{
//do something
}
};

class Function2
{
public:
void WhatDude()
{
Function1: :Dude();
}
};


[ 07 February 2001: Message edited by: f'lar ]

Gweedo
02-07-2001, 04:42 PM
thanks. I get it know. ;)