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. 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
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.
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.
"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).
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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
|
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...
|
by: Dumitru Sipos |
last post by:
Hello everybody!
is there possible to have a function that is both static and virtual?
Dumi.
|
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;
|
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...
|
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...
|
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:...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
|
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...
| |