Solved

Syntax of const pointer reference.

Posted on 1998-06-01
12
236 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

Suggested Solutions

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

734 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