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. Writing a Factory Design Pattern Program with separate Header Files and Class Implementations

Writing a Factory Design Pattern Program with separate Header Files and Class Implementations

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpdesignregexarchitecture
3 Posts 2 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.
  • L Offline
    L Offline
    Litu Sahoo
    wrote on last edited by
    #1

    Hi, I am trying to learn factory design pattern in c++, writing a program with separate header files and their class implementations in .cpp files. But i am facing problem. I was trying the ShapeFactory from where we implement Circle and Rectangle. invalid new-expression of abstract class type 'Circle' invalid new-expression of abstract class type 'Rectangle' But i am getting these errors and also few other errors. Can someone please help on this. Regards Litu

    L 2 Replies Last reply
    0
    • L Litu Sahoo

      Hi, I am trying to learn factory design pattern in c++, writing a program with separate header files and their class implementations in .cpp files. But i am facing problem. I was trying the ShapeFactory from where we implement Circle and Rectangle. invalid new-expression of abstract class type 'Circle' invalid new-expression of abstract class type 'Rectangle' But i am getting these errors and also few other errors. Can someone please help on this. Regards Litu

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      "new" ... you can't instantiate an "abstract" class; you need to subclass it first or use an existing derived class.

      It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

      1 Reply Last reply
      0
      • L Litu Sahoo

        Hi, I am trying to learn factory design pattern in c++, writing a program with separate header files and their class implementations in .cpp files. But i am facing problem. I was trying the ShapeFactory from where we implement Circle and Rectangle. invalid new-expression of abstract class type 'Circle' invalid new-expression of abstract class type 'Rectangle' But i am getting these errors and also few other errors. Can someone please help on this. Regards Litu

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Your Shape class should be the only abstract one. Circle and Rectangle should be complete classes that inherit Shape. There is a very good set of articles on factory patterns by @SneshPrajapati here on CodeProject, starting with Factory Patterns - Simple Factory Pattern[^].

        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