Solved

Error C3254 compiling template class

Posted on 2015-01-22
1
336 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now