I have code like this :
void foo(int i, void* p) { .. }
class A
{
public:
A();
~A();
private:
void foobar(int i, char* c);
};
Is there a way for foo to call foobar() ? 3 1671
Lucy Ludmiller wrote:
I have code like this :
void foo(int i, void* p) { .. }
class A
{
public:
A();
~A();
private:
void foobar(int i, char* c);
};
Is there a way for foo to call foobar() ?
Sure:
void foo(int i, void* p)
{
A a;
a.foobar(i, static_cast<char*>(p));
}
But if your question is, can foo call foobar without an instance of
class A to call it with, the answer is no, unless you change foobar to
be a static member of A.
Best regards,
Tom
Thomas Tutone wrote:
Lucy Ludmiller wrote:
I have code like this :
void foo(int i, void* p) { .. }
class A
{
public:
A();
~A();
private:
void foobar(int i, char* c);
};
Is there a way for foo to call foobar() ?
Sure:
void foo(int i, void* p)
{
A a;
a.foobar(i, static_cast<char*>(p));
}
.... if class A declares foo as a friend:
class A
{
friend void foo(int i, void* p) ;
//.....
};
HTH
Radu
>
But if your question is, can foo call foobar without an instance of
class A to call it with, the answer is no, unless you change foobar to
be a static member of A.
you can declaring
Best regards,
Tom
Radu wrote:
Thomas Tutone wrote:
Lucy Ludmiller wrote:
I have code like this :
>
void foo(int i, void* p) { .. }
>
class A
{
public:
A();
~A();
private:
void foobar(int i, char* c);
};
>
Is there a way for foo to call foobar() ?
Sure:
void foo(int i, void* p)
{
A a;
a.foobar(i, static_cast<char*>(p));
}
... if class A declares foo as a friend:
class A
{
friend void foo(int i, void* p) ;
//.....
};
Good point - I missed that foo was private. Thanks for the
clarification.
Best regards,
Tom This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Midas |
last post by:
Greetings everyone,
I'm including code, for cut/paste, to better explain my question. I create a Car object then I call some of its methods. No problem. Then I try to pass, to a function, the name...
|
by: Marijn |
last post by:
I'd like to know how compilers usually handle static variables that
are declared inside a function (as opposed to static class-members).
Like in:
int counter(){
static int c=0;
++c;
return c;...
|
by: George Vodpik |
last post by:
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <e1$RDGmfEHA.2200@TK2MSFTNGP09.phx.gbl>
Newsgroups: microsoft.public.dotnet.general...
|
by: Jonathan Roewen |
last post by:
Hi
I've got loading assemblies dynamically done (wasn't too difficult). Now I want to lookup a static function in the loaded assembly, and if found, return it somehow, and call it from my app. So...
|
by: Pujo Aji |
last post by:
I have a problem with an object calling outside method:
Forexample in the main part I have an object and the object will do
something time independent, and after it is finished working it should ...
| |
by: Kylin |
last post by:
which situation should use the static function ?
--
FireCrow Studio
Kylin Garden
EMail:w0wd@sohu.com
ICQ:156134382
|
by: csharpula csharp |
last post by:
Hello,
I am parsing some main arguments and calling to functions according to
it. Is it possible not to define the called functions as static? How can
I design it better?
Thanks
*** Sent via...
|
by: PaowZ |
last post by:
Hello there!
I have to call a bunch of static functions where class names are
stored in a array.
So I have: $my_array = array("class_1","class_2", ... and so on...)
So I tried this piece of...
|
by: Omar.Khalid79 |
last post by:
Hi Guys,
Maybe this is silly thing to ask but I have a static function declared
static void Foo(int a);
defined in Foo.cpp
and a member method which calls Foo
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |