C++ static function

P

prsudhe

Hi,


How can we create a effect of C++ static function without using
the keyword static?

Thanks ...
 
P

Puppet_Sock

How can we create a effect of C++ static function without using
the keyword static?

Do you mean, how can you get a member function of an object
to be like a static without using the keyword static?

If so, you can't. Member functions have an implied "this" that
tells the function what instance of the class is being called.

There are ways to "get around" this, depending on what your
context is. What are you trying to do?
Socks
 
F

Frederick Gotham

Victor Bazarov posted:
Try not to do somebody's homework here, will you?


If that's a homework question, then the teacher is incompetant.

"Hi, today I'm going to teach you about transmissions. Your homework is to go
find out how transmissions work."
 
V

Victor Bazarov

Frederick said:
Victor Bazarov posted:



If that's a homework question, then the teacher is incompetant.

I thought it was difficult to find somebody with a quicker judgment
on Usenet than myself... The teacher is not incompetent by giving
such homework assignments. The student is definitely lazy if he
tries to get the answer instead of researching it.

Besides, it could be a homework not given by a teacher; it looks
very much like an interview question from one of those "get ready
to be a C++ programmer by answering all those interview questions"
sites.

V
 
F

Frederick Gotham

Victor Bazarov posted:
Besides, it could be a homework not given by a teacher; it looks
very much like an interview question from one of those "get ready
to be a C++ programmer by answering all those interview questions"
sites.


Maybe I'm narrow-minded, but here's an analogy that crept into my head:

Imagine I have a 4 year old son. He comes home from school one day and
asks me, "Daddy, what letter comes after G in the alphabet? Our teacher
told us to go find out.". Do I:

(a) Deem the teacher to be great for making the children go out and
learn things for themselves.

or:

(b) Scorn the teacher for not teaching my son the alphabet.

A teacher's job is to teach, not to instruct the student to go off and
figure things out for themselves. When I was at school, I had many
incompetant teachers (one of the perks of growing up in a working-class
area -- although I could never quite understand why they call it working-
class if the people don't actually work...) who regularly didn't teach, and
instead instructed the students to go off and learn things for themselves.
Result? Well it seems a little inconsistent that after 6 years of high
school, I'm fluent in one of the human languages I learned, and can't
string a sentence together in the other.

Don't tell a student, "Go off an figure out how we implement internal
linkage in C++". At the VERY least, instruct them to Google for "anonymous
namespace".
 
V

Victor Bazarov

Frederick said:
[...]
Imagine I have a 4 year old son. He comes home from school one day
and asks me, "Daddy, what letter comes after G in the alphabet? Our
teacher told us to go find out.". Do I:

(a) Deem the teacher to be great for making the children go out and
learn things for themselves.

or:

(b) Scorn the teacher for not teaching my son the alphabet.

Huh? Ever heard of "tests"? First you teach, then you ask to perform
a task to see how well the pupil has absorbed the material.

How is giving a task to do something relatively simple negates the
possibility that it _has_ been taught, in your mind?
[...nonsensical complaint about a bad school attended removed...]

We all went to bad schools. Doesn't mean there aren't normal schools
out there.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top