Solved

Error C3254 compiling template class

Posted on 2015-01-22
1
371 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:khun
1 Comment
 
LVL 8

Accepted Solution

by:
khun 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

770 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