Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4620694
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:35:42+00:00 2026-05-22T02:35:42+00:00

So I have the following (very simple) code: int* pInt = new int(32); std::cout<<

  • 0

So I have the following (very simple) code:

int* pInt = new int(32);

std::cout<< pInt << std::endl;  //statement A
std::cout<< *pInt << std::endl; //statement B
std::cout << &pInt << std::endl; //statement C

So here’s what I think I am doing (I have learned that in C++ I am rarely ever doing what I think I am doing):

  1. Creating a pointer to an integer and calling it pInt
  2. statementA prints the address of the value ’32’
  3. statementB prints the integer value that is being pointed to by my pointer (which is done because I dereference the pointer, thus giving me access to what it is pointing to).
  4. statementC prints the address of the pointer itself (not the address of the integer value ’32’).

Is all of this correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:35:42+00:00Added an answer on May 22, 2026 at 2:35 am

    Your second statement is wrong. You allocate a new int off the heap. The compile-time constant “32” does not have an address, and therefore you cannot take it. You create an int whose value is 32. This is not the same thing.

    int* pInt1 = new int(32);
    int* pInt2 = new int(32);
    

    pInt1 and pInt2 are not equal.

    Oh, one last thing- C++ is a pretty strongly typed language, and it’s pretty unnecessary to prefix variable names with type data. This is called Hungarian Notation, it’s very common in Microsoft C libraries and samples, but generally unnecessary here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following very simple code - int x=15000 int z=0.7*x cout<<z =
I have got the following very simple code: function init() { var articleTabs =
I have the following PHP code doing a very simple select into a table.
This is very weird. I have the following code: Assert.AreEqual(new DateTime(2000, 1, 1), DateTime.ParseExact(2000,
I have a very simple c code: #include<stdio.h> int main() { enum boolean{true,false}; boolean
I have the very simple following code: main.cpp #include ui_library_browser.h #include <QtGui/QApplication> #include StartWindow.h
I have the following code that does something very simple: visits recursively a tree
I have the following code to do a some very simple validation for a
I have a very simple html page with the following javascript in it $(function()
I have the following line of code called very often: var configValue = System.Configuration.ConfigurationManager.AppSettings[ConfigValueKey];

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.