Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. From C to C++ Pointer

From C to C++ Pointer

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jw81
    wrote on last edited by
    #1

    I have C background but I need something like pointer so store two double variable data. Could anyone show me how or post some tutorial website here? Thanks.

    D M 2 Replies Last reply
    0
    • J jw81

      I have C background but I need something like pointer so store two double variable data. Could anyone show me how or post some tutorial website here? Thanks.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      One way:

      double d1 = 5.1;
      double *p1 = &d1;

      Another:

      double *p1 = new double;
      *p1 = 1.8;


      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      J 1 Reply Last reply
      0
      • D David Crow

        One way:

        double d1 = 5.1;
        double *p1 = &d1;

        Another:

        double *p1 = new double;
        *p1 = 1.8;


        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        J Offline
        J Offline
        jw81
        wrote on last edited by
        #3

        Thx I am using VC++, any easier class in MFC? The way you used seemed like C.

        D 1 Reply Last reply
        0
        • J jw81

          I have C background but I need something like pointer so store two double variable data. Could anyone show me how or post some tutorial website here? Thanks.

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          store where and how ?

          double* d1;
          double* d2;

          d1 = new double;
          *d1 = 0.4;

          d2 = new double;
          *d2 = 0.3;


          Maximilien Lincourt Your Head A Splode - Strong Bad

          1 Reply Last reply
          0
          • J jw81

            Thx I am using VC++, any easier class in MFC? The way you used seemed like C.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            jw81 wrote: any easier class in MFC? What I provided was not easy? Are you sure that you understand what you are asking? A pointer in C is the same pointer in C++. Encapsulating a simple pointer into a C++ class is unnecessary.


            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            J 1 Reply Last reply
            0
            • D David Crow

              jw81 wrote: any easier class in MFC? What I provided was not easy? Are you sure that you understand what you are asking? A pointer in C is the same pointer in C++. Encapsulating a simple pointer into a C++ class is unnecessary.


              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              J Offline
              J Offline
              jw81
              wrote on last edited by
              #6

              My mistake, I was thinking abt linked list. Sorry abt the confusion. Does VC++ linked list same as C? Thanks.

              M 1 Reply Last reply
              0
              • J jw81

                My mistake, I was thinking abt linked list. Sorry abt the confusion. Does VC++ linked list same as C? Thanks.

                M Offline
                M Offline
                Maximilien
                wrote on last edited by
                #7

                yes; all C constructs are C++ compatible. but I would suggest using either MFC collections or STL collections


                Maximilien Lincourt Your Head A Splode - Strong Bad

                J 1 Reply Last reply
                0
                • M Maximilien

                  yes; all C constructs are C++ compatible. but I would suggest using either MFC collections or STL collections


                  Maximilien Lincourt Your Head A Splode - Strong Bad

                  J Offline
                  J Offline
                  jw81
                  wrote on last edited by
                  #8

                  Thanks Maximilien, This is the actual question I am asking, could you suggest any MFC function that I can use for such case (linked list)? There are quite a lot of solution from MFC but I dont know which one is the best. If it is too difficult to show here could you post any url related to such case? Thanks.

                  T 1 Reply Last reply
                  0
                  • J jw81

                    Thanks Maximilien, This is the actual question I am asking, could you suggest any MFC function that I can use for such case (linked list)? There are quite a lot of solution from MFC but I dont know which one is the best. If it is too difficult to show here could you post any url related to such case? Thanks.

                    T Offline
                    T Offline
                    ThatsAlok
                    wrote on last edited by
                    #9

                    jw81 wrote: I can use for such case (linked list)? Look for Collection Classes in MSDN. Some of them are

                    • Clist
                    • CPtrArray
                    • CArray

                    or In STL

                    • std::list
                    • std::vector

                    "I Think this Will Help"  Alok Gupta
                     visit me at http://www.thisisalok.tk

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups