473,405 Members | 2,415 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,405 software developers and data experts.

Questions about const reference

What's the difference between (const MyClass &) and (MyClass const &)?
And when to use which? Thanks.

Feb 1 '06 #1
2 1406
* D'artagnan:

What's the difference between (const MyClass &) and (MyClass const &)?
The first has 'const' first, the second has 'const' in the middle.

And when to use which? Thanks.


Use the one you prefer for readability.

For consistency some prefer the second version; for similarity to other
languages, or some other reason, some prefer the first version.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Feb 1 '06 #2
D'artagnan wrote:
What's the difference between (const MyClass &) and (MyClass const &)?
And when to use which? Thanks.


It's in the FAQ:

http://www.parashift.com/c++-faq-lit....html#faq-18.8

Best regards,

Tom

Feb 1 '06 #3

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

Similar topics

3
by: Stub | last post by:
Question 1: class Count { public: Count() : id(n++) { cout << id << " default ctor" << endl; } Count(Count const&) : id(n++) { cout << id << " copy ctor" << endl; Count (Count const& src) :...
2
by: David List | last post by:
I posed a MySQL C API question a few days back here, and got zero answers. I assume it is because this is not the right place to ask such questions. Does anyone here know where I could ask C API...
3
by: CoolPint | last post by:
If I were to design my own container and its iterators, I understand that I need to provide both "iterator" and "const_iterator" so that begin() and end() return appropriate ones depending on the...
14
by: MSR | last post by:
I have a couple of questions. 1. Copy Constructor. class A { private: int a1; double d1; char *ptr;
6
by: Last Timer | last post by:
I need help with the following questions: a) if a class has virtual functions, is it better to make the destructor virtual b) can a friend function be inherited c) if a function argument is...
15
by: Pelle Beckman | last post by:
Hi all, I have a few newbie questions: In function declaration what does a 'const' mean inside the parameter list ? That it won't modify the value? void MemberFunction(const int x);
12
by: Sashi | last post by:
All, I had an interview today and I couldn't answer these questions. Any good answers? Why does a copy constructor param need to be const? Ever need a virtual constructor? Major difference...
39
by: Digital Puer | last post by:
I'm not the world's greatest C++ programmer, so I had a hard time with these. Some help would be appreciated. 1. Comment on the declaration of function Bar() below: class Foo { static int...
25
by: Syam | last post by:
Fully answered interview questions in c and c++ from http://www.faiqs.com
14
by: shamirza | last post by:
Question Do ActiveX DLLs made in VB still need the VB runtimes on the machine? ________________________________________ Answer In a word, Yes. Visual Basic does not support what is known...
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: 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
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
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...
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.