473,387 Members | 3,821 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,387 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 2684

<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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.