Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,998 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,349 people online right now. Registration is fast and FREE... Join Now!




pointer question

 
Reply to this topicStart new topic

pointer question

mahaveer
22 Nov, 2006 - 02:04 AM
Post #1

New D.I.C Head
*

Joined: 22 Nov, 2006
Posts: 3


My Contributions
why cannot we find out the address of an integer constants? huh.gif
User is offlineProfile CardPM
+Quote Post

horace
RE: Pointer Question
22 Nov, 2006 - 02:29 AM
Post #2

D.I.C Addict
Group Icon

Joined: 25 Oct, 2006
Posts: 573



Thanked: 5 times
Dream Kudos: 50
My Contributions
QUOTE(mahaveer @ 22 Nov, 2006 - 10:04 AM) *

why cannot we find out the address of an integer constants? huh.gif

not sure what you mean?
CODE

    const int i=10;
    cout << " i = "  << i << " address is " << &i << endl;

should work OK
User is offlineProfile CardPM
+Quote Post

Xing
RE: Pointer Question
22 Nov, 2006 - 08:51 AM
Post #3

D.I.C Addict
Group Icon

Joined: 22 Jul, 2006
Posts: 723



Thanked: 4 times
Dream Kudos: 1575
My Contributions
QUOTE(mahaveer @ 22 Nov, 2006 - 03:34 PM) *

why cannot we find out the address of an integer constants? huh.gif

In case of C++ most of the time memory is not allocated for compile time constants(though it depends on how you use it). If ,however, you take an address of a const(even unknowingly, by passing it to a function that takes reference argument) or you define it as extern, then storage is created for const.

This post has been edited by Xing: 22 Nov, 2006 - 08:51 AM
User is offlineProfile CardPM
+Quote Post

ushasuvarsh
RE: Pointer Question
5 Dec, 2006 - 04:46 AM
Post #4

New D.I.C Head
*

Joined: 3 Dec, 2006
Posts: 2


My Contributions
\u sizeof()
User is offlineProfile CardPM
+Quote Post

Xing
RE: Pointer Question
5 Dec, 2006 - 05:27 AM
Post #5

D.I.C Addict
Group Icon

Joined: 22 Jul, 2006
Posts: 723



Thanked: 4 times
Dream Kudos: 1575
My Contributions
QUOTE(ushasuvarsh @ 5 Dec, 2006 - 06:16 PM) *

\u sizeof()


What?
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 08:20PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month