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 1037949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:54:48+00:00 2026-05-16T14:54:48+00:00

I am trying to implement a closest point program. Here is the code: #include

  • 0

I am trying to implement a closest point program. Here is the code:

#include <iostream>
#include <cstdlib>
#include <math.h>
using namespace std;

float randfloat(){
    return 1.0*rand()/RAND_MAX;
}

class point
{
    public :
    float x,y;

    float distance(point& a){
        float dx=x-a.x;
        float dy=y-a.y;
        return  sqrt(dx*dx+dy*dy);
    }
};

int main(int argc,char* argv[]){
    int i,cnt=0;
    int n=atoi(argv[1]);
    float d=atof(argv[2]);
    point *a=new point[n];
    for (int i=0;i<n;i++)
    {
        a[i].x=randfloat();
        a[i].y=randfloat();
    }
    for (i=0;i<n;i++)
        for (int j=i+1;j<n;j++)
            if ((distance(a[i],a[j])<d)) cnt++;
    cout << cnt << "pairs within" << d << endl;

    return 0;
}

But when I compile it from the command line it gives an error like this:

pointer is not member of base class point

Here is the full list:

    C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\xutility(373) : error C
2039: 'iterator_category' : is not a member of 'point'
        closet_point.cpp(9) : see declaration of 'point'
        closet_point.cpp(37) : see reference to class template instantiation 'st
d::iterator_traits<_Iter>' being compiled
        with
        [
            _Iter=point
        ]
C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\xutility(373) : error C
2146: syntax error : missing ';' before identifier 'iterator_category'
C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\xutility(373) : error C
4430: missing type specifier - int assumed. Note: C++ does not support default-i
nt
C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\xutility(373) : error C
2602: 'std::iterator_traits<_Iter>::iterator_category' is not a member of a base
 class of 'std::iterator_traits<_Iter>'
        with
        [
            _Iter=point
        ]

How can I fix this problem?

  • 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. Editorial Team
    Editorial Team
    2026-05-16T14:54:49+00:00Added an answer on May 16, 2026 at 2:54 pm

    I believe that you are using the wrong distance() function. I believe you meant

    a[i].distance(a[j])

    instead of

    distance(a[i],a[j])

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying implement a bracket in my program (using C#/.NET MVC) and I am
I am trying implement the Data transformation using Reflection 1 example in my code.
Trying to implement a search similar to here .This searches properties based on city,locality,property
Im trying to implement a bezier curve and line segment intersection test. The closest
I have been trying to implement this code , where i capture a image
I'm trying to implement the times() function in C programming. I'm using the struct
I am trying to implement a snap grid using WPF and a canvas. I
I'm trying to implement a comet style, long polling connection using an XMLHttpResponse object.
I am trying to implement a SQLite example found on Android10 . The code
I am trying to implement a slide down for table rows using the previous

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.