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. Managed C++/CLI
  4. Base class pointer to derived class object???

Base class pointer to derived class object???

Scheduled Pinned Locked Moved Managed C++/CLI
question
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.
  • A Offline
    A Offline
    Ash20
    wrote on last edited by
    #1

    what is advantage of "Base class pointer to Derived Class object" ? class Base { public: Base(){ cout<<"Constructor: Base"<fun1(); I guess it is having same behaviour. Please let me know wht is advantage of using base class pointer to derived class object? Thanks\ Ash.

    C E 2 Replies Last reply
    0
    • A Ash20

      what is advantage of "Base class pointer to Derived Class object" ? class Base { public: Base(){ cout<<"Constructor: Base"<fun1(); I guess it is having same behaviour. Please let me know wht is advantage of using base class pointer to derived class object? Thanks\ Ash.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      In this instance, none. However, if you have many different derived classes, you can create a collection of the base class to hold them all, and if the base class defines a generic interface, an instance of the base class can do many things, depending on what derived class the instance is. This question is in the wrong forum, BTW. This is for .NET questions only.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • A Ash20

        what is advantage of "Base class pointer to Derived Class object" ? class Base { public: Base(){ cout<<"Constructor: Base"<fun1(); I guess it is having same behaviour. Please let me know wht is advantage of using base class pointer to derived class object? Thanks\ Ash.

        E Offline
        E Offline
        etkid84
        wrote on last edited by
        #3

        pretty sure.

        David

        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