Solved

Syntax of const pointer reference.

Posted on 1998-06-01
12
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

615 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