?
Solved

Error C3254 compiling template class

Posted on 2015-01-22
1
Medium Priority
?
436 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

719 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