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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:33:47+00:00 2026-06-17T13:33:47+00:00

struct vect{ float x,y,z; vect(float xx, float yy, float zz){ x=xx; y=yy; z=zz; }

  • 0
struct vect{
    float x,y,z;
    vect(float xx, float yy, float zz){
        x=xx;
        y=yy;
        z=zz;
    }
    vect(){
        x=0;
        y=0;
        z=0;
    }
    void normalize(){
        float len = sqrt(x*x + y*y + z*z);
        x = x/len;
        y = y/len;
        z = z/len;
    }
    vect operator-(const vect &other) const{return vect(x-other.x,y-other.y,z-other.z);}
};

bool tri_plane_x(vect *v1, vect *v2, vect *v3, vect *pos, float s){

    //removed unnessecary code

    if (vv1 != vv2){
        vect dir = v2 - v1; // getting an error on this line
        dir.normalize();
        float d = (pos->x - v1->x)/dir.x;
        hy[c] = d * dir.y + v1->y;
        hz[c] = d * dir.z + v1->z;
        c++;
    }

    //removed unnessecary code
}

do some one know why this wont compile? is there a error in how i overloaded the function or is this because i am subtracting two pointers to a vect?

./exporter/main.cpp:74:19: error: conversion from ‘long int’ to non-scalar type ‘vect’ requested

here is the compiler error related to this line. (didn’t include the whole log as it is just a the same error repeated many times in the code)

i can’t see where the “long int” comes from… is there another way of overloading when using pointers?

  • 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-06-17T13:33:48+00:00Added an answer on June 17, 2026 at 1:33 pm

    v2 and v1 are pointers, the difference between two pointers is a number telling you the offset between two addresses, which is a number.

    You don’t want to “overload using pointers” you want the result of operator- on the objects pointed to, not on the pointers themselves.

    You need to say *v2 - *v1 to dereference the pointers and access the objects they point to.

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

Sidebar

Related Questions

struct MemBlock { char mem[1024]; MemBlock operator*(const MemBlock &b) const { return MemBlock(); }
struct A { A(const A& src); A(const char* src); }; struct B { operator
struct that { that &frob() { return *this; } that frob() const { return
struct B { }; struct A { operator A&() const; operator B&() const; };
struct Foo { int data; Foo() = default; Foo(const Foo& arg) = default; };
struct A {}; struct B { B (A* pA) {} B& operator = (A*
struct B { void (B::*pf)(int, int); // data member B () : pf(&B::foo) {}
struct Div { int i; int j; }; class A { public: A(); Div&
struct A { int a; virtual void print() {} }; struct B : A
struct hostent *lh = gethostbyname(hostname); int socketDescriptor = socket(AF_INET,SOCK_STREAM, 0); sockaddr_in socketInfo; memset(&socketInfo, 0,

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.