Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 132425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:15:38+00:00 2026-05-11T06:15:38+00:00

I am wondering why the following contrived example code works perfectly fine in Visual

  • 0

I am wondering why the following contrived example code works perfectly fine in Visual Studio 2005, but generates an error in GCC (‘no matching function to call’ when calling Interpolate() as shown below).

Also, how do I work around this? It seems that the error message is just a generic message because GCC did not have a more specific message for the actual reason of the problem and it had to output something. I’m a bit at a loss on how to proceed porting this class without some really ugly workarounds.

namespace Geo {     template <class T>     class TMyPointTemplate     {         T X,Y;     public:         inline TMyPointTemplate(): X(0), Y(0) {}         inline TMyPointTemplate(T _X,T _Y): X(_X), Y(_Y) {}         inline T GetX ()const { return X; }         inline T GetY ()const { return Y; }         //...         template<T> TMyPointTemplate<T> Interpolate(const TMyPointTemplate<T> &OtherPoint)const         {             return TMyPointTemplate((X+OtherPoint.GetX())/2,(Y+OtherPoint.GetY())/2);         }                };     typedef TMyPointTemplate<int> IntegerPoint; }  Geo::IntegerPoint Point1(0,0); Geo::IntegerPoint Point2(10,10); Geo::IntegerPoint Point3=Point1.Interpolate(Point2); //GCC PRODUCES ERROR: no matching function for call to 'Geo::TMyPointTemplate<int>::Interpolate(Geo::IntegerPoint&)' 

Thanks for your help,

Adrian

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:15:38+00:00Added an answer on May 11, 2026 at 6:15 am

    I don’t think you need the template there at all in the function definition, since it is defined inline with the class

    TMyPointTemplate Interpolate(const TMyPointTemplate &OtherPoint)const { 

    should do.

    And when you do use the template for defining the function not inline, I think you need the class keyword in there like this.

    template<class T> // <- here TMyPointTemplate<T> TMyPointTemplate<T>::Interpolate(const TMyPointTemplate<T> &OtherPoint)const { 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering how one could use template databinding to accomplish what the following code
i was wondering if the following code would cause some problems like memory leak
I'm wondering why the following piece of code doesn't work, looks pretty straight-forward, am
I am wondering what the following line of code is doing: @property (assign, nonatomic)
Inspired by this question I began wondering why the following examples are all illegal
I am new to git. I am wondering whether the following scenario is supported,
With a vector defined as std::vector<std::string> , Wondering why the following is valid: if
I'm wondering how you'd implement the following use-case in REST. Is it even possible
Just wondering what the difference between MFC control messages prefixed with the following is:
Just wondering if there is a better way to write the following PL/SQL piece

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.