Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set pointer in Main

0 views
Skip to first unread message

Peter_APIIT

unread,
Jul 2, 2009, 4:48:22 AM7/2/09
to
Hello to all, i have declare some pointer and set it to point to some
instance but when i debug it, i cannot check from debugger.

Why this happening?

[code]
usernameType* theAccountType = theAccountUser.FactoryMethodCreate
(loginSession);
Human* theRealPosition = theAccountType->getInstance();

[/code]

theAccountType and theRealPosition are not in local and autos also.

Why this happening ?

Thanks for your help.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Martin T.

unread,
Jul 2, 2009, 9:48:47 PM7/2/09
to
Peter_APIIT wrote:
> Hello to all, i have declare some pointer and set it to point to some
> instance but when i debug it, i cannot check from debugger.
>

It's always nice to start with which compiler, which debugger, which system.

> Why this happening?
>
> [code]
> usernameType* theAccountType = theAccountUser.FactoryMethodCreate
> (loginSession);
> Human* theRealPosition = theAccountType->getInstance();
>
> [/code]
>
> theAccountType and theRealPosition are not in local and autos also.
>

Since you are talking local and autos I will assume that you are using
*a* version of visual studio.

> Why this happening ?
>

Post a full code example. And especially provide information where your
debugger is currently stopped and what you *do* see in the autos and
local list.

Apart from that, this probably belongs to a Visual studio specific NG.
(try microsoft.public.vc.language or microsoft.public.vc.debugger)

br,
Martin

Ron

unread,
Jul 2, 2009, 9:56:06 PM7/2/09
to
On Jul 2, 4:48 am, Peter_APIIT <peterap...@gmail.com> wrote:
> Hello to all, i have declare some pointer and set it to point to some
> instance but when i debug it, i cannot check from debugger.
>
> Why this happening?
>
> [code]
> usernameType* theAccountType = theAccountUser.FactoryMethodCreate
> (loginSession);
> Human* theRealPosition = theAccountType->getInstance();
>
> [/code]
>
> theAccountType and theRealPosition are not in local and autos also.
>
> Why this happening ?

From the sound of your letter it sounds like you're using Visual
Studio to debug (locals and autos are two of the windows in
that product). Your question is better asked in a forum
having microsoft in it's name. Try hovering the mouse over
the variable name for a quick look or type the name in the
"watch" window.

If these variables are defined in a class or at namespace
(global) scope, they won't show up in locals because they
are not, and the compiler populates auto with it's idea of
what is important that may not coincide with yours.

red floyd

unread,
Jul 3, 2009, 12:06:49 AM7/3/09
to
On Jul 2, 1:48 am, Peter_APIIT <peterap...@gmail.com> wrote:
> Hello to all, i have declare some pointer and set it to point to some
> instance but when i debug it, i cannot check from debugger.

Perhaps you should ask in a forum dedicated to your platform (from
below, I gather it's MSVS).
MSVS has many online support forums. How to use a specific tool is
not really on-topic here.

Please see FAQ 5.9
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Peter_APIIT

unread,
Jul 3, 2009, 12:11:05 PM7/3/09
to
On Jul 3, 9:48 am, "Martin T." <0xCDCDC...@gmx.at> wrote:
> Peter_APIIT wrote:
> > Hello to all, i have declare some pointer and set it to point to some
> > instance but when i debug it, i cannot check from debugger.
>
> It's always nice to start with which compiler, which debugger, which system.
>
> > Why this happening?
>
> > [code]
> > usernameType* theAccountType = theAccountUser.FactoryMethodCreate
> > (loginSession);
> > Human* theRealPosition = theAccountType->getInstance();
>
> > [/code]
>
> > theAccountType and theRealPosition are not in local and autos also.
>
> Since you are talking local and autos I will assume that you are using
> *a* version of visual studio.
>
> > Why this happening ?
>
> Post a full code example. And especially provide information where your
> debugger is currently stopped and what you *do* see in the autos and
> local list.
>
> Apart from that, this probably belongs to a Visual studio specific NG.
> (try microsoft.public.vc.language or microsoft.public.vc.debugger)

{ quoted sig & banner removed. don't quote extraneous material. tia., -mod }

OK, i post the main code here and the local and auto variable i see at
a specific break point.

[code]
int main()
{
SystemIntro staffPersonnelSystem;
staffPersonnelSystem();

login loginSession;
loginSession();

usernameType theAccountUser(loginSession);


usernameType* theAccountType = theAccountUser.FactoryMethodCreate
(loginSession);

[Break point here].

theAccountType->ForwardCreator();

MenuOption anOption(loginSession);


Human* theRealPosition = theAccountType->getInstance();

theRealPosition->CallBack(anOption() );


[/code]

Autos
loginSession
theAccountUser

Local
anOption
loginSession
theAccountUser


There are no error in return type of those calls.

Peter_APIIT

unread,
Jul 3, 2009, 12:23:23 PM7/3/09
to
On Jul 3, 12:06 pm, red floyd <redfl...@gmail.com> wrote:
> On Jul 2, 1:48 am, Peter_APIIT <peterap...@gmail.com> wrote:
>
> > Hello to all, i have declare some pointer and set it to point to some
> > instance but when i debug it, i cannot check from debugger.
>
> Perhaps you should ask in a forum dedicated to your platform (from
> below, I gather it's MSVS).
> MSVS has many online support forums. How to use a specific tool is
> not really on-topic here.
>
> Please see FAQ 5.9http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

{ quoted banner removed. please don't quote extraneous material. tia., -mod }

I think this issues is not related to compiler since i test it with a
simple program like this.

int number(10);
int* ptr = &number;

It eventually, i can check ptr in auto and local window.

Thanks.

Peter_APIIT

unread,
Jul 4, 2009, 8:39:21 AM7/4/09
to
I have found where the problem.

I have class contains pointer to newly dynamic created object.

I set the pointer nicely but after return to main The pointer no
longer valid.

[code]
usernameType theAccountUser(loginSession);

usernameType* theAccountType(theAccountUser.FactoryMethodCreate
(loginSession));
theAccountType->ForwardCreator();

void AdministratorType::ForwardCreator()
{
// Forward call to AdminFactory
AdministratorObjectFactory adminFactoryObject;

setInstance(adminFactoryObject.createInstance());
}
// =========================================
void AdministratorType::setInstance(Human* myInstance)
{
theInstance = myInstance;
}


[/code]

theInstance is member of usernameType derived class.

theInstance is valid after the execution of setInstance() but invalid
in main.

Why this happening ?

red floyd

unread,
Jul 4, 2009, 8:40:44 AM7/4/09
to
Peter_APIIT wrote:
> On Jul 3, 12:06 pm, red floyd <redfl...@gmail.com> wrote:
>> On Jul 2, 1:48 am, Peter_APIIT <peterap...@gmail.com> wrote:
>>
>>> Hello to all, i have declare some pointer and set it to point to some
>>> instance but when i debug it, i cannot check from debugger.
>> Perhaps you should ask in a forum dedicated to your platform (from
>> below, I gather it's MSVS).
>> MSVS has many online support forums. How to use a specific tool is
>> not really on-topic here.
>>

> I think this issues is not related to compiler since i test it with a


> simple program like this.
>
> int number(10);
> int* ptr = &number;
>
> It eventually, i can check ptr in auto and local window.

The fact that you can't see something in your debugger is a toolset
issue. Use of your tools - in particular, your IDE and debugger - is
not related to the C++ language proper, and are better addressed in
a forum for your toolset.

Again, please see FAQ 5.9, for a list of suggested places where you
might get a better answer.

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

0 new messages