const function??

F

franco ziade

what does this declaration mean?

void function_name() const
{}

This means that the function is constant? what is the implication?

Thanks
 
T

Tom St Denis

franco said:
what does this declaration mean?

void function_name() const
{}

This means that the function is constant? what is the implication?

It means you have broken code. Did you even try to compile it?

laptop ~ # gcc -Wall -W -O2 -c test.c
test.c: In function `function_name':
test.c:2: error: parse error before '{' token

I mean you might as well ask what

for_lots_of_items (int i = 0 through 3; while i < fourteen; add to i)
display me i please;

means...

Tom
 
J

Jens.Toerring

franco ziade said:
what does this declaration mean?
void function_name() const
{}
This means that the function is constant? what is the implication?

Are you sure this is supposed to be C and not C++? If it is C++
then you're in the wrong group, please ask in comp.lang.c++. In
C this function declaration is a syntax error.

Regards, Jens
 
E

E. Robert Tisdale

franco said:
what does this declaration mean?
class X {
public:
void function_name(void) const { } };

This means that the function is constant? what is the implication?

You are probably reading C++ code.
It looks like a member function definition
taken out of the context of the class definition.
 
J

Jens.Toerring

E. Robert Tisdale said:
class X {
public:
You are probably reading C++ code.
It looks like a member function definition
taken out of the context of the class definition.

What's going on here? What Franco Ziade wrote was:

|| what does this declaration mean?
||
|| void function_name() const
|| {}
||
|| This means that the function is constant? what is the implication?

What you're "citing" has three lines that never were in the post by
Franco Ziade and of the rest you have "edited" one line. So why are
you (again) "citing" something that has never been posted?
 
K

Keith Thompson

What's going on here? What Franco Ziade wrote was:

|| what does this declaration mean?
||
|| void function_name() const
|| {}
||
|| This means that the function is constant? what is the implication?

What you're "citing" has three lines that never were in the post by
Franco Ziade and of the rest you have "edited" one line. So why are
you (again) "citing" something that has never been posted?

If you look carefully, you'll see that ERT correctly marked the lines
he added. In this followup, the OP's line is marked with ">>>", and
the added lines with ">>" (though the original line didn't have the
"{ }" that ERT added to it). He could have been clearer about what he
was doing, though.
 
C

CBFalconer

Keith said:
If you look carefully, you'll see that ERT correctly marked the lines
he added. In this followup, the OP's line is marked with ">>>", and
the added lines with ">>" (though the original line didn't have the
"{ }" that ERT added to it). He could have been clearer about what
he was doing, though.

Yes, I was ready to castigate also. However on NS 4.7x quoted
material is in a different typeface than new material, so things
stand out better. I guess ERT does so many trollish things that we
are overly ready to discover another. Every time he shows signs of
reforming he seems to fall off the wagon again. But this is not a
fall :)
 
D

DHOLLINGSWORTH2

franco ziade said:
what does this declaration mean?

void function_name() const
{}

This means that the function is constant? what is the implication?

Thanks

This means you expect us to read your programming manual for you.
 
U

uououo

class foo{
public:
void bar();
};
void foo::bar()const{ }


////////////////////////////////////////

const foo a;
a.bar();///////////////////////////
 
J

Jens.Toerring

Yes, I was ready to castigate also. However on NS 4.7x quoted
material is in a different typeface than new material, so things
stand out better. I guess ERT does so many trollish things that we
are overly ready to discover another. Every time he shows signs of
reforming he seems to fall off the wagon again. But this is not a
fall :)

Sorry, I apologize to ERT on the count of adding lines. I don't on
the count of editing lines he's citing (there never was a 'void' in
the original post).
Regards, Jens
 

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

Forum statistics

Threads
474,159
Messages
2,570,881
Members
47,418
Latest member
NoellaXku

Latest Threads

Top