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. ATL / WTL / STL
  4. Derived class from a template base class

Derived class from a template base class

Scheduled Pinned Locked Moved ATL / WTL / STL
questionc++help
2 Posts 2 Posters 2 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.
  • Y Offline
    Y Offline
    yellowine
    wrote on last edited by
    #1

    If I have a c++ template class declared in Point.hpp file as below

    template <typename>
    class Point
    {
    ....
    }

    If I want a new class derived from the above class in Node.hpp file but the data type is specialized to be double:

    class Node: public Point<double>
    {
    ...
    }

    When I compile the codes, the compiler complains that in Node.hpp that the base class Point is undefined. I know that I have included Point.hpp in Node.hpp. Why that error? Or how can I derived a node class (which should be a non template class) from a template Point class with double data type?

    L 1 Reply Last reply
    0
    • Y yellowine

      If I have a c++ template class declared in Point.hpp file as below

      template <typename>
      class Point
      {
      ....
      }

      If I want a new class derived from the above class in Node.hpp file but the data type is specialized to be double:

      class Node: public Point<double>
      {
      ...
      }

      When I compile the codes, the compiler complains that in Node.hpp that the base class Point is undefined. I know that I have included Point.hpp in Node.hpp. Why that error? Or how can I derived a node class (which should be a non template class) from a template Point class with double data type?

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      After fixing your posted fake code to be real code it compiles fine for me

      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