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
  • 3 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 why the following code doesn't work: String test = new String(new byte[]
I'm wondering if the following is possible. I know it doesn't work, but maybe
I was wondering why the following code: <asp:ComboBox ID=DropDown1 runat=server Width=30px AutoCompleteMode=None AutoPostBack=false DropDownStyle=DropDown
Wondering if following will work for google in robots.txt Disallow: /*.action I need to
Just wondering if the following is considered to be good programming practice or not?
Just wondering how the following sql query would look in linq for Entity Framework...
Just wondering if the following expressions used for Value are equivalent (the column Contrib
I am wondering why the following two types struct { double re[2]; }; and
I was wondering if the following is possible. Create a class that accepts an
I was wondering if the following is common for regular Java applications when receiving

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.