member function and member variable 
Author Message
 member function and member variable

I'm using Dialog based application and want to alter the value of some
windows control.
It seems that the member variable is accessible only inside the member
functions, is that true?
How about a simple function I write which is not a member function? can I
call the member variable inside? If not, what should I do?


Wed, 07 Jul 2004 01:06:47 GMT  
 member function and member variable
Walk to the bookstore.  Buy a copy of "C++ Primer" by Stan Lippman.  This
has *nothing* to do with Windows CE at all.

Paul T.


Quote:
> I'm using Dialog based application and want to alter the value of some
> windows control.
> It seems that the member variable is accessible only inside the member
> functions, is that true?
> How about a simple function I write which is not a member function? can I
> call the member variable inside? If not, what should I do?



Wed, 07 Jul 2004 01:29:49 GMT  
 member function and member variable

Quote:
>Walk to the bookstore.  Buy a copy of "C++ Primer" by Stan Lippman.  This
>has *nothing* to do with Windows CE at all.

The problem is that the message was heavily cross-posted. It's a fair
question to ask in microsoft.public.vc.language, however.

Chad



Wed, 07 Jul 2004 07:56:50 GMT  
 member function and member variable

Quote:

>I'm using Dialog based application and want to alter the value of some
>windows control.
>It seems that the member variable is accessible only inside the member
>functions, is that true?

If you declare them as "public:", you can access them outside the
class like this:

classname::myvariable

Quote:
>How about a simple function I write which is not a member function? can I
>call the member variable inside?

Sure; just refer to the variable that way (although, I'm not sure why
you'd want to. It kinda defeats the purpose of "classes taking care of
their own members".

HTH

Chad



Wed, 07 Jul 2004 07:58:58 GMT  
 member function and member variable


Oops. Wrong attribution line. Sorry everybody :/

Chad



Wed, 07 Jul 2004 09:28:06 GMT  
 member function and member variable

Quote:


> >I'm using Dialog based application and want to alter the value of some
> >windows control.
> >It seems that the member variable is accessible only inside the member
> >functions, is that true?

> If you declare them as "public:", you can access them outside the
> class like this:

> classname::myvariable

Yes, but you shouldn't do that unless you really know what you're doing
(which judging by the original message, the OP doesn't).


Sat, 10 Jul 2004 00:58:42 GMT  
 member function and member variable

Quote:

> Walk to the bookstore.  Buy a copy of "C++ Primer" by Stan Lippman.

And Lajoie, I believe?

Other beginner's C++ book reviews:
http://www.accu.org/bookreviews/public/reviews/0sb/beginner_s_c__.htm



Sat, 10 Jul 2004 01:00:44 GMT  
 member function and member variable



Quote:
> It's a shame that we don't have the ability to automatically send a
message
> to every account when they first post to the newsgroup:

> 1. Look for answers to previously asked questions in www.dejanews.com.
> 2. Don't post the same basic message separately to a pile of newsgroups.
> 3. Don't cross-post to newsgroups not associated with your question.
> 4. Recommended books for Windows CE:...
> 5. Recommended books for Visual Basic programming...
> 6. Recommended books for C++ programming...

> Anyone at Microsoft want to take on doing this?

Um, I think anyone at MS doing it would probably be accused of bias (for
example, a lot of the recommended texts would probably come from MS Press).

I had considered writing a FAQ, but past experience has shown that people
don't read FAQs before posting - despite it being in the
news.answers.new-users FAQ...

--
Mike Dimmick



Sun, 11 Jul 2004 04:04:27 GMT  
 member function and member variable
Yea, it really needs to be automatic and based on a database of previous
posters.

Paul T.


Quote:



> > It's a shame that we don't have the ability to automatically send a
> message
> > to every account when they first post to the newsgroup:

> > 1. Look for answers to previously asked questions in www.dejanews.com.
> > 2. Don't post the same basic message separately to a pile of newsgroups.
> > 3. Don't cross-post to newsgroups not associated with your question.
> > 4. Recommended books for Windows CE:...
> > 5. Recommended books for Visual Basic programming...
> > 6. Recommended books for C++ programming...

> > Anyone at Microsoft want to take on doing this?

> Um, I think anyone at MS doing it would probably be accused of bias (for
> example, a lot of the recommended texts would probably come from MS
Press).

> I had considered writing a FAQ, but past experience has shown that people
> don't read FAQs before posting - despite it being in the
> news.answers.new-users FAQ...

> --
> Mike Dimmick



Sun, 11 Jul 2004 05:42:12 GMT  
 member function and member variable
Yep. Create a member variable for the control (see my essay on my MVP Tips site on
avoiding GetDlgItem) and you can then use it to change the control, e.g.,
        c_Name.SetWindowText(YourNameHere);
There is never a reason to use what you call "a simple function" when you need access to a
class member; in fact, the use of a non-member function says, explicitly, "I don't want
access to the class members". (If you use one, you have to pass in the class pointer
explicitly, so it might as well be a member function and do it for you!). There is no
advantage, and significant disadvantages. Rewrite the function as a member function. If it
is a callback or some other function that must be static, you have to pass in an
appropriate pointer for it to work. If it is a timer callback, rewrite it to use WM_TIMER
messages (OnTimer).
                                joe

Quote:

>I'm using Dialog based application and want to alter the value of some
>windows control.
>It seems that the member variable is accessible only inside the member
>functions, is that true?
>How about a simple function I write which is not a member function? can I
>call the member variable inside? If not, what should I do?

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Fri, 16 Jul 2004 12:25:06 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. member function and member variable

2. member function and member variable

3. static function access member variable and member function

4. Private member access in a different function member

5. viewing member functions of an object in the debug variables window

6. C2086 error: static local variables in member functions

7. class view dosen't shows member variable's and functions defined with macros

8. Macro to create Get/Set functions from a member variable

9. pointer to member function/variable info?

10. forcing __cdecl convention on member functions without variable arguments

11. static variable defined in a member function

12. Function Pointer as a member variable

 

 
Powered by phpBB® Forum Software