What is shallow copying

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • santoshramancha
    New Member
    • Mar 2008
    • 7

    What is shallow copying

    hi all. can anyone give the source code for shallow copying?
  • fual
    New Member
    • Feb 2008
    • 28

    #2
    Originally posted by santoshramancha
    hi all. can anyone give the source code for shallow copying?
    Shallow copy usually means copying a pointer, rather than the underlying data; this means changes to the copied object will be reflected in the original. You can probably supply your own "source code" now.

    Comment

    • mvjohn100
      New Member
      • Mar 2008
      • 57

      #3
      In c++ there is default copy constructer or assingment operator. it using shallow copying. so it is the default one.for deep copy only we want the coding.

      Comment

      • gpraghuram
        Recognized Expert Top Contributor
        • Mar 2007
        • 1275

        #4
        Originally posted by santoshramancha
        hi all. can anyone give the source code for shallow copying?

        Search using shallow copy/deep copy in th net and you ill get examples for this

        Raghuram

        Comment

        • fual
          New Member
          • Feb 2008
          • 28

          #5
          Originally posted by mvjohn100
          In c++ there is default copy constructer or assingment operator. it using shallow copying. so it is the default one.for deep copy only we want the coding.
          The default behaviour is to copy! Deep and shallow are just programming concepts. The notion of shallow copying comes from the fact that if you copy a pointer you are copying a memory address; as such your copied object contains a pointer that points at the same place as your original object's pointer.

          In essence "shallow copy" means to copy a pointer directly rather than constructing a copied pointer via new.

          Comment

          Working...