473,976 Members | 2,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

const function??

what does this declaration mean?

void function_name() const
{}

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

Thanks
Nov 14 '05 #1
10 1558

franco ziade wrote:
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_ite ms (int i = 0 through 3; while i < fourteen; add to i)
display me i please;

means...

Tom

Nov 14 '05 #2
franco ziade <fz****@videotr on.ca> wrote:
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
--
\ Jens Thoms Toerring ___ Je***********@p hysik.fu-berlin.de
\______________ ____________ http://www.toerring.de
Nov 14 '05 #3
franco ziade wrote on 25/02/05 :
what does this declaration mean?

void function_name() const
{}


Nothing. Parse error.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"Mal nommer les choses c'est ajouter du malheur au
monde." -- Albert Camus.

Nov 14 '05 #4
franco ziade wrote:
what does this declaration mean?
class X {
public: void function_name(v oid) 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.
Nov 14 '05 #5
E. Robert Tisdale <E.************ **@jpl.nasa.gov > wrote:
franco ziade wrote:
what does this declaration mean?
class X {
public:
void function_name(v oid) 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.


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?
--
\ Jens Thoms Toerring ___ Je***********@p hysik.fu-berlin.de
\______________ ____________ http://www.toerring.de
Nov 14 '05 #6
Je***********@p hysik.fu-berlin.de writes:
E. Robert Tisdale <E.************ **@jpl.nasa.gov > wrote:
franco ziade wrote:
what does this declaration mean?

class X {
public:
void function_name(v oid) 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.


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.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #7
Keith Thompson wrote:
Je***********@p hysik.fu-berlin.de writes:
E. Robert Tisdale <E.************ **@jpl.nasa.gov > wrote:
franco ziade wrote: what does this declaration mean?

class X {
public:
void function_name(v oid) 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.


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.


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 :-)

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #8

"franco ziade" <fz****@videotr on.ca> wrote in message
news:N4******** ************@we ber.videotron.n et...
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.
Nov 14 '05 #9
class foo{
public:
void bar();
};
void foo::bar()const { }
////////////////////////////////////////

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

Nov 14 '05 #10

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

Similar topics

19
2824
by: Christian Engström | last post by:
If you have a function that returns something by value, the gcc compiler (version 3.2.3 on Windows XP with MinGW) converts the returned value from the type you specify in the code, to the const version of that type. Is this a bug that is specific to gcc, or is it a flaw in the language specification that gcc diligently implements? For example, the below program produces the output Constant Mutable
2
3656
by: joe | last post by:
hi, after reading some articles and faq, i want to clarify myself what's correct(conform to standard) and what's not? or what should be correct but it isn't simply because compilers don't support. (first i compiled them with g++3.x. ERR means compiler will bark, otherwise it does accept it. Then the Comeau C/C++ 4.3.3 comes)
7
3813
by: johny smith | last post by:
Can someone please explain to me the difference between these two: function1( const int a) function2( int const a) Both seemed to compile, but what is the difference between the two above. And why would one choose one over the other. moreover, I thought there was a difference between the two below where one would not let the value change whereas the other one would not let the
7
4383
by: al | last post by:
char s = "This string literal"; or char *s= "This string literal"; Both define a string literal. Both suppose to be read-only and not to be modified according to Standard. And both have type of "const char *". Right? But why does the compiler I am using allow s to be modified, instead of generating compile error?
8
2604
by: Roger Leigh | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 A lot of functions use const pointer arguments. If I have a non-const pointer, it is transparently made const when I pass it to the function, e.g. char * -> const char *. However, this does not appear to work when I add another level of indirection: void test1 (char **value) {}
8
10151
by: andrew.fabbro | last post by:
In a different newsgroup, I was told that a function I'd written that looked like this: void myfunc (char * somestring_ptr) should instead be void myfunc (const char * somestring_ptr) When I asked why, I was told that it facilitated calling it as:
20
2503
by: Snis Pilbor | last post by:
Whats the point of making functions which take arguments of a form like "const char *x"? It appears that this has no effect on the function actually working and doing its job, ie, if the function doesn't write to x, then it doesnt seem like the compiler could care less whether I specify the const part. Quite the opposite, if one uses const liberally and then later goes back and changes the functions, headaches will inevitably occur as...
16
3184
by: hzmonte | last post by:
Correct me if I am wrong, declaring formal parameters of functions as const, if they should not be/is not changed, has 2 benefits; 1. It tells the program that calls this function that the parameter will not be changed - so don't worry. 2. It tells the implementor and the maintainer of this function that the parameter should not be changed inside the function. And it is for this reason that some people advocate that it is a good idea to...
4
6712
by: grizggg | last post by:
I have searched and not found an answer to this question. I ran upon the following statement in a *.cpp file in a member function: static const char * const pacz_HTMLContentTypeHeader = "Content-Type: text/html\r\n"; Why is the second const needed and what does it do? Thanks
6
2416
by: .rhavin grobert | last post by:
hello;-) i frequently need the following construction: ReturnParam § Function() § { /...do something.../ someType var § = something; /...do something.../ return something;
0
10171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11408
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10084
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8462
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6416
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3761
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.