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

Functions

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabasehelp
4 Posts 3 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.
  • B Offline
    B Offline
    bhangie
    wrote on last edited by
    #1

    Hi Can someone please help me with this. :( Given the following-> Write a function called Copy, witch takes two parameters of type string. The first par is your Source(string to be copied) second is your Dest string(target) this function need not return anything(NOT ALLOWED TO USE strcpy) I need to show how i would use this function(call) by writing code that copy one string into another. A deep copy should take place not Shallow. How can i implement the following in my function clear, erase, resize, append and index operator. How does the following piece of code look? #include #include using namespace std; void Copy(string * Source, string * Destination);//???? int main() { string Source = "Robile"; string Destination = "Lance"; Source.append(Destination); Copy(&Source , &Destination); } void Copy(string * Source, string * Destination) { cout << "Destination String Now is " << *Destination << "\n"; } Not asking for complete code just tips on what to do and howto(Correction of code above) Thanks in advance

    T B 2 Replies Last reply
    0
    • B bhangie

      Hi Can someone please help me with this. :( Given the following-> Write a function called Copy, witch takes two parameters of type string. The first par is your Source(string to be copied) second is your Dest string(target) this function need not return anything(NOT ALLOWED TO USE strcpy) I need to show how i would use this function(call) by writing code that copy one string into another. A deep copy should take place not Shallow. How can i implement the following in my function clear, erase, resize, append and index operator. How does the following piece of code look? #include #include using namespace std; void Copy(string * Source, string * Destination);//???? int main() { string Source = "Robile"; string Destination = "Lance"; Source.append(Destination); Copy(&Source , &Destination); } void Copy(string * Source, string * Destination) { cout << "Destination String Now is " << *Destination << "\n"; } Not asking for complete code just tips on what to do and howto(Correction of code above) Thanks in advance

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      what do you want to know ? how to write member functions ? other thing, don't you prefer operator=() instead of Copy() ??


      TOXCCT >>> GEII power

      1 Reply Last reply
      0
      • B bhangie

        Hi Can someone please help me with this. :( Given the following-> Write a function called Copy, witch takes two parameters of type string. The first par is your Source(string to be copied) second is your Dest string(target) this function need not return anything(NOT ALLOWED TO USE strcpy) I need to show how i would use this function(call) by writing code that copy one string into another. A deep copy should take place not Shallow. How can i implement the following in my function clear, erase, resize, append and index operator. How does the following piece of code look? #include #include using namespace std; void Copy(string * Source, string * Destination);//???? int main() { string Source = "Robile"; string Destination = "Lance"; Source.append(Destination); Copy(&Source , &Destination); } void Copy(string * Source, string * Destination) { cout << "Destination String Now is " << *Destination << "\n"; } Not asking for complete code just tips on what to do and howto(Correction of code above) Thanks in advance

        B Offline
        B Offline
        bhangie
        wrote on last edited by
        #3

        firstly how to write a function prototype that does a deep copy (not a copy of the values only). Secondly how would i write a member function from your perspective. What is the deference between operator=() and Copy()? The code above compiles but is it the write way to do it taking what i have stated in my thread in to mind?

        D 1 Reply Last reply
        0
        • B bhangie

          firstly how to write a function prototype that does a deep copy (not a copy of the values only). Secondly how would i write a member function from your perspective. What is the deference between operator=() and Copy()? The code above compiles but is it the write way to do it taking what i have stated in my thread in to mind?

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

          bhangie wrote: ...a function prototype that does a deep copy I've never seen the adjective "deep" used with "copy." What does it mean? bhangie wrote: What is the deference between operator=() and Copy()? Fundamentally, nothing. It's all a matter of how you want to use it. Which of these looks more natural:

          Object a, b;
          a.Copy(b);
          // or
          a = b;


          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          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