Solved

Error C3254 compiling template class

Posted on 2015-01-22
1
419 Views
Last Modified: 2015-01-22
Hi!

I have the following quite simple helper class to use with for_each to add 2D points to a 2D or 3D point vector. I have compiled this many times, but after some minor code change I suddenly get compiler error "error C3254: 'MyClass' : class contains explicit override '()' but does not derive from an interface that contains the function declaration" and can't see why? Any tips appreciated!
    template <class P>
    class solutionAdd
    {
    public:
      solutionAdd(std::vector<P>& solutions, const double elevation = 0.0) : 
         m_solutions(solutions), m_elevation(elevation) {}
      void operator()(const std::pair<double, Point2D>& breakPoint)
      {
        m_solutions.push_back(breakPoint.second);
      }
    private:
         std::vector<P>& m_solutions;
         double m_elevation;
    };
    template<> 
     void solutionAdd<Point3D>::operator()(const std::pair<double, Point2D>& breakPoint) 
    { 
      m_solutions.push_back(Point3D(breakPoint.second.GetX(), breakPoint.second.GetY(), m_elevation));
    }

Open in new window

I'm certainly overlooking something obvious here...
0
Comment
Question by:Knut Hunstad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
Knut Hunstad earned 0 total points
ID: 40564060
And as soon as I wrote this I found the error: I had moved this from outside the declaration of "MyClass" _into_ the class declaration...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question