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. CString

CString

Scheduled Pinned Locked Moved C / C++ / MFC
testingbeta-testingquestion
7 Posts 5 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.
  • P Offline
    P Offline
    p_1960
    wrote on last edited by
    #1

    Hi , When i try to do as follows. CString strString=_T("testing"); int nSize=sizeof(strString); now nSize gets a value =4; how the size is getting 4 strString is a pointer..? i guess it is an object... Please clarify..

    N C K 3 Replies Last reply
    0
    • P p_1960

      Hi , When i try to do as follows. CString strString=_T("testing"); int nSize=sizeof(strString); now nSize gets a value =4; how the size is getting 4 strString is a pointer..? i guess it is an object... Please clarify..

      N Offline
      N Offline
      Nishad S
      wrote on last edited by
      #2

      p_1960 wrote:

      i guess it is an object...

      Yes... :) If you look into the code of CString you will get the answer.

      - ns ami -

      P 1 Reply Last reply
      0
      • P p_1960

        Hi , When i try to do as follows. CString strString=_T("testing"); int nSize=sizeof(strString); now nSize gets a value =4; how the size is getting 4 strString is a pointer..? i guess it is an object... Please clarify..

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        p_1960 wrote:

        i guess it is an object...

        No need to guess: CString is a ATL/MFC class [^]. A class instance is an object. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        1 Reply Last reply
        0
        • N Nishad S

          p_1960 wrote:

          i guess it is an object...

          Yes... :) If you look into the code of CString you will get the answer.

          - ns ami -

          P Offline
          P Offline
          p_1960
          wrote on last edited by
          #4

          then why the size of CString is 4..?

          N 1 Reply Last reply
          0
          • P p_1960

            then why the size of CString is 4..?

            N Offline
            N Offline
            Nishad S
            wrote on last edited by
            #5

            The size of a class object is the sum of size of all the non static members. If you check the CString class (as I told before) you can find only one member inside it. ie., LPTSTR m_pchData;

            - ns ami -

            C 1 Reply Last reply
            0
            • N Nishad S

              The size of a class object is the sum of size of all the non static members. If you check the CString class (as I told before) you can find only one member inside it. ie., LPTSTR m_pchData;

              - ns ami -

              C Offline
              C Offline
              chandu004
              wrote on last edited by
              #6

              thanks for a convincing explanation. :) actually i got carried away by some other false assumption. :doh:

              1 Reply Last reply
              0
              • P p_1960

                Hi , When i try to do as follows. CString strString=_T("testing"); int nSize=sizeof(strString); now nSize gets a value =4; how the size is getting 4 strString is a pointer..? i guess it is an object... Please clarify..

                K Offline
                K Offline
                KarstenK
                wrote on last edited by
                #7

                CString is an object which has some methods as GetLength() which will return the lenght of the incorporated string. :doh: Plaese clarify your question... :sigh:

                Press F1 for help or google it. Greetings from Germany

                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