473,396 Members | 1,891 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,396 software developers and data experts.

I could not get this const before a function declaration

I understand that a const qualifier after the function declaration
makes it a const function for the class.

Like

int func1 const ( double, long int );

Now what is the purpose of the following
const int func1 const ( double, long int );
What is the purpose of the const before the declaration

-Parag
Jun 27 '08 #1
2 2686

<pa********@hotmail.comwrote in message
news:f0**********************************@i18g2000 prn.googlegroups.com...
>I understand that a const qualifier after the function declaration
makes it a const function for the class.

Like

int func1 const ( double, long int );
Actualy, it's like this:

int func1 ( double, long int ) const;
Now what is the purpose of the following
const int func1 const ( double, long int );
const int func1 ( double, long int ) const;

would be a constant function that returns a constant integer. Really not
making much sense, usually a const returned value is a reference or pointer
such as:

const int & func1 ( double, long int ) const;
or
const int* func1 ( double, long int ) const;
What is the purpose of the const before the declaration

Jun 27 '08 #2
On Jun 16, 7:44 am, "Jim Langston" <tazmas...@rocketmail.comwrote:
<parag_p...@hotmail.comwrote in message
news:f0**********************************@i18g2000 prn.googlegroups.com...
I understand that a const qualifier after the function
declaration makes it a const function for the class.
Like
int func1 const ( double, long int );
Actualy, it's like this:
int func1 ( double, long int ) const;
Now what is the purpose of the following
const int func1 const ( double, long int );
const int func1 ( double, long int ) const;
would be a constant function that returns a constant integer.
Really not making much sense,
Not much sense, since const-ness doesn't apply to rvalues of
non-class type. It is reasonable for a class type.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #3

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

Similar topics

1
by: Blace Ice | last post by:
HI, Pls. see the following function declaration: int foo(const char *); How to get the return typename and parameter typenames from the declaration? For example, I need some codes like the...
19
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...
6
by: franco ziade | last post by:
what does this declaration mean in C++ void func_name() const { ... } is this a const function ? what are the implications? thanks
27
by: Sundar | last post by:
Do we have something called a const function ? I thought applying the 'const' specifier to a function is meaningless... but when i tried defining a const function it worked !! like... const int...
10
by: franco ziade | last post by:
what does this declaration mean? void function_name() const {} This means that the function is constant? what is the implication? Thanks
1
by: INeedADip | last post by:
What is the difference between: function setupGrid( param ){......} and setupGrid = function( param ){......} Are there any advantages to doing one over the other?
1
by: wtu | last post by:
function Declaration&Definition -------------------------------------------------------------------------------- " Geroty (const vector<Point3D>& poly, const Plane& Tr)" As i'm c++ beginner...
1
by: Lawrence Spector | last post by:
Base base; BaseWrap& baseWrap(reinterpret_cast<BaseWrap&>(base)); boost::python::object obj(boost::shared_ptr<BaseWrap>(&baseWrap)); // Compile error Results in this error: ...
13
by: Sri Harsha Dandibhotla | last post by:
Hello all. I recently came across a function declaration as : char(*(*x()))(); This was not in some code but it was in a C questions thread on some group. I tried to decipher what it returns but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.