Newsgroups: comp.lang.c++,comp.object,comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!EU.net!sun4nl!hacktic!ijssel!arnoud
From: arnoud@ijssel.xs4all.nl (Arnoud Martens)
Subject: Re: static/nonstatic member functions
References: <1995Jan11.143449.24323@rcmcon.com> <3f10h3$1c4@crchh917.bnr.ca> <1995Jan16.200908.2541@rcmcon.com> <D2Iq7C.3L0@markv.com>
Followup-To: comp.lang.c++
Organization: IJssel service
Date: Wed, 18 Jan 1995 11:41:32 GMT
Message-ID: <D2Ln59.Bs@ijssel.xs4all.nl>
Reply-To: arnoudm@ijssel.xs4all.nl
Lines: 39
Xref: glinda.oz.cs.cmu.edu comp.lang.c++:108332 comp.object:25310 comp.lang.smalltalk:19707

In article <D2Iq7C.3L0@markv.com>, Dan Smith <dans@markv.com> wrote:
>Static data members are generally thought of as "class" members while
>non-static data members are "instance" members (more or less).
>
>Is there any such distinction for static/non-static member functions?  If not,
>how can a static member function be interpreted in C++?

You can think of static member functions as functions that belong
to the domain of the class but don't actually modify an object
(that is they don;t need a this pointer). Possible uses might be
maniupation and querying of static varaibles. I have also seen
static functions used like this:

class String{
public:
	            String(const char*);
            String& upperCase();
     static String& upperCase(const String&);
};

So if you have:

String myStr("a String");

// call static version does not modify myStr, newStr = "A STRING"
String newStr =  String::upperCase(myStr); 
// call member function, myStr is modified
myStr::upperCase();                       

Gtx:

Note: Followup to comp.lang.c++




-- 
Name: Arnoud Martens, Utrecht, the Netherlands,  tel: +31-30-732679
E-mail: arnoudm@ijssel.xs4all.nl WWW: http://www.xs4all.nl/~arnoudm
