Object

G

Guest

Hi

Consider the sample .NET 2003 Windows Form application
In winmain we got
Application::Run(new Form1()) instruction which creates the instance (object) of Form1 class.
But how can I use the methods of this object by its name
If I want to use these methods in Form1 class I use "this->" oprerator but what if want to run
them from another class (assuming they are public)?. How can I reference them? By which name
 
J

Jacobo Rodriguez

Artek said:
Hi,

Consider the sample .NET 2003 Windows Form application.
In winmain we got
Application::Run(new Form1()) instruction which creates the instance (object) of Form1 class.
But how can I use the methods of this object by its name?
If I want to use these methods in Form1 class I use "this->" oprerator but what if want to run
them from another class (assuming they are public)?. How can I reference them? By which name?
Form1 *form = new Form1();
form->Method1();
form->Method2();
..
..
..
Application::Run(form);

--
Jacobo Rodríguez Villar

Proyectos en desarrollo:

http://www.typhoonlabs.com
 
G

Guest

That's right but "form" is only visible in winmain function. What if I want to cal
form->Method1() from eg. some differnet class or differnet included cpp file

--
Artur

----- Jacobo Rodriguez wrote: ----

Artek wrote
Hi
In winmain we got
Application::Run(new Form1()) instruction which creates the instance (object) of Form1 class.
But how can I use the methods of this object by its name
If I want to use these methods in Form1 class I use "this->" oprerator but what if want to run
them from another class (assuming they are public)?. How can I reference them? By which name
Form1 *form = new Form1()
form->Method1()
form->Method2()
 
G

Guest

I'm thinking you have to pass a pointer to where ever you want to use the form at. Or maybee you could use the scope resolution operatior ::
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top