Solved

Syntax of const pointer reference.

Posted on 1998-06-01
12
232 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

947 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

20 Experts available now in Live!

Get 1:1 Help Now