Solved

Syntax of const pointer reference.

Posted on 1998-06-01
12
234 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

785 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