Solved

Syntax of const pointer reference.

Posted on 1998-06-01
12
231 Views
Last Modified: 2010-04-02
Ignoring the issue that is surely a bad program design.  I need to return a reference to a constant pointer.  The syntax

const Obj * &

is wrong, it means that the thing pointed to is constant.  I believe that what I want is

Obj * const &

Is that correct?  Also can I do this with a non-pointer. Like does

int const &

mean the same as

const int &
0
Comment
Question by:nietod
12 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1165052
Yes and Yes.
R U sure you want to waste points on that?
0
 
LVL 11

Expert Comment

by:alexo
ID: 1165053
const binds to the left except when it's the first token.
0
 
LVL 2

Expert Comment

by:VEngineer
ID: 1165054

Are you trying to do a reference return?  Or is this a parameter being passed?

0
 
LVL 11

Expert Comment

by:alexo
ID: 1165055
That is, the thing to the left of the const is constant (unless the const is the first token of the declaration, then the thing to the right of the const is constant).

Beware geeks bearing GIFs!
0
 
LVL 22

Author Comment

by:nietod
ID: 1165056
>> the thing to the left of the const is constant (unless the const is the first
>> token of the declaration, then the thing to the right of the const is constant)

This language is a mess!  The only thing worse than writting in it would be writting a compiler for it!

Why don't you answer, Alex?

0
 
LVL 4

Expert Comment

by:sganta
ID: 1165057
char *y="testing";
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 22

Author Comment

by:nietod
ID: 1165058
Was that meant for a different question?  It seems to have nothing to do with my question.  Besides my question was answered and I invited Alexo to submit an answer.
0
 
LVL 11

Accepted Solution

by:
alexo earned 20 total points
ID: 1165059
I thought that taking your points for this question would be unfair but if you insist...
0
 
LVL 22

Author Comment

by:nietod
ID: 1165060
Now do I let this sit around and be Autograded?????  I guess not.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1165061
>> Now do I let this sit around and be Autograded?????
Hell, why not?  I already got Roger "subtly suggesting" all over the place that customers reject my answers and Andrewyu shouting "thank you!" and gracing my answer with a D...

0
 
LVL 22

Author Comment

by:nietod
ID: 1165062
Yeah, but you aren't in it for the points.... right?  
0
 
LVL 11

Expert Comment

by:alexo
ID: 1165063
Right.  But sometimes the attitudes of some (or the terminal stupidity of others) get to me...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now