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. constructor and copy constructor

constructor and copy constructor

Scheduled Pinned Locked Moved C / C++ / MFC
3 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
    bobi_zcl
    wrote on last edited by
    #1

    Hi,my class definement is as follows: class A { public: A(){cout<<"A::A()"<

    T M 2 Replies Last reply
    0
    • B bobi_zcl

      Hi,my class definement is as follows: class A { public: A(){cout<<"A::A()"<

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

      i'm not sure of the output, but the first thing i see is that you derive A and its destructor (A::~A()) is not declared as virtual... i think so the output is:

      A::A()
      A::A()
      B::B()
      A::~A()
      A::~A()

      is is wrong ? (i did not compile to test, so i may have written an error, but that was the game, wasn't it ? :-D )


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      1 Reply Last reply
      0
      • B bobi_zcl

        Hi,my class definement is as follows: class A { public: A(){cout<<"A::A()"<

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        bobi_zcl wrote: what is the output result?why? Why don't you step through it yourself and find out? :^) Note that the code in main() won't work on VC7.x, the declarations of a and b will be treated as function prototypes, not variable declarations. If you use 7.x you'll need to change it to:

        A a = A();
        A b = B();

        --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD

        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