473,323 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

static member functions

Hello Grp,
Correct me if I am wrong.
static member functions can act only on static member varaibles.It can
accessed by using the name of the class.
Then why is there an access controller.

what does a private static member function mean?

Thaanx in advance for any advice
Rgds,
Naren.
Jul 19 '05 #1
5 9361


Naren wrote:

Hello Grp,
Correct me if I am wrong.
static member functions can act only on static member varaibles.It can
accessed by using the name of the class.
Then why is there an access controller.

Why should there not be?
what does a private static member function mean?


That it can be called from ordinary member functions of
the same class only.

Eg. It can be used for helper functions, which don't need
access to object internal data.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 19 '05 #2
Naren wrote:
Hello Grp,
Correct me if I am wrong.
static member functions can act only on static member varaibles.
No. A static member function isn't called for a specific object, so it
doesn't have a "this" pointer or an object to operate on. If you crate
an object locally, reference an external object or get one passed as
parameter, you can access anything from it.
It can accessed by using the name of the class.
Yes.
Then why is there an access controller.
Access control is unrelated to static member functions.
what does a private static member function mean?


That it's a static function that can only be called by member functions
of the same class and by friends of that class.

Jul 19 '05 #3
In article <bg**********@ns2.fe.internet.bosch.com>,
na*************@in.bosch.com says...
Hello Grp,
Correct me if I am wrong.
static member functions can act only on static member varaibles.
Okay, you're wrong. A static member function can act on a non-static
member variable as long as it has an instance of the object to act on.
Also consider something like a static member function being used as a
call-back function. Nothing outside the class needs access to it by
name, but it has to be a static function to have the correct type.
It can
accessed by using the name of the class.
Yes. And so?
Then why is there an access controller.
To control access, of course. <G>
what does a private static member function mean?


It means the name is only visible to other class members, just like
private does with anything else.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 19 '05 #4

"Jerry Coffin" <jc*****@taeus.com> wrote in message
news:MP************************@news.clspco.adelph ia.net...
In article <bg**********@ns2.fe.internet.bosch.com>,
na*************@in.bosch.com says...
Hello Grp,
Correct me if I am wrong.
static member functions can act only on static member varaibles.


Okay, you're wrong. A static member function can act on a non-static
member variable as long as it has an instance of the object to act on.
Also consider something like a static member function being used as a
call-back function. Nothing outside the class needs access to it by
name, but it has to be a static function to have the correct type.


The function would look like:

void method(CYourClass* pYourClass)
{
pYourClass->PublicMember = 0;
}

Only public members can be accessed(unless it is declared as a "friend" but
that gets into something else).
Jul 19 '05 #5
David T. Croft wrote:
> Correct me if I am wrong.
> static member functions can act only on static member varaibles.


Okay, you're wrong. A static member function can act on a non-static
member variable as long as it has an instance of the object to act
on. Also consider something like a static member function being used
as a
call-back function. Nothing outside the class needs access to it by
name, but it has to be a static function to have the correct type.


The function would look like:

void method(CYourClass* pYourClass)
{
pYourClass->PublicMember = 0;
}

Only public members can be accessed(unless it is declared as a
"friend" but that gets into something else).


If the above is supposed to be a static member function of CYourClass,
then this is not true. Making a member static or not is in no way
related to access rights. It's a member function, so it can access all
the members of the class.
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Alexander Mahr | last post by:
Dear Newsgroup, I'm somehow confused with the usage of the static keyword. I can see two function of the keyword static in conjunction with a data member of a class. 1. The data member...
4
by: 0to60 | last post by:
I don't know if I have that terminology right, but does anyone know if static member functions (or free standing functions for that matter) are any less overhead than actual member functions that...
3
by: exits funnel | last post by:
Hello, One of the problems at the end of Chapter 14 in Bruce Eckel's thinking in C++ reads as follows: Create a class with two static member functions. Inherit from this class and redefine...
30
by: Joost Ronkes Agerbeek | last post by:
Why is it allowed in C++ to call a static member function of an object through an instance of that object? Is it just convenience? tia, Joost Ronkes Agerbeek
11
by: Roger Leigh | last post by:
The C++ book I have to hand (Liberty and Horvath, Teach yourself C++ for Linux in 21 Days--I know there are better) states that "static member functions cannot access any non-static member...
6
by: Dumitru Sipos | last post by:
Hello everybody! is there possible to have a function that is both static and virtual? Dumi.
3
by: paul.furber | last post by:
Hi all, I have some code which looks a bit like this: #define Offset(m, T) ((size_t)(&((T *)1)->m) - 1) class Point: private: int *x,*y;
15
by: Samee Zahur | last post by:
Question: How do friend functions and static member functions differ in terms of functionality? I mean, neither necessarily needs an object of the class to be created before they are called and...
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
10
by: shanknbake | last post by:
I'm getting the following compile-time error: error C2352: 'Person::getCount' : illegal call of non-static member function Here is my getCount function declaration:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.