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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:59:03+00:00 2026-06-03T21:59:03+00:00

I have two pointers (const Vec* a and const Vec b) in a given

  • 0

I have two pointers (const Vec* a and const Vec b)
in a given piece of code, I need to pass these two values​​, which are instantiated during the code, for a function that has no parameter (const Vec *) but only (Vec *).
How could I do this without moving the function definition, but if necessary, what procedure should I take?

//const Vec* from;
//const Vec* at;
Vec* viewVec; 
viewVec = Vec::sub( view->at, view->from);


//static Vec* sub(Vec*, Vec*);
Vec* Vec::sub(Vec* a, Vec* b) {
    return new Vec(a->x - b->x, a->y - b->y, a->z - b->z);
}
  • 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-03T21:59:05+00:00Added an answer on June 3, 2026 at 9:59 pm

    You can use const_cast for this, e.g.

    viewVec = Vec::sub(const_cast<Vec*>(view->at), const_cast<Vec*>(view->from));
    

    Whether or not you should is another matter. If you really can’t change the signature of the function (which is probably the easiest fix), you can always write a wrapper which contains the dodgy casting – that way, at least the caller doesn’t need to do any casting itself:

    Vec *Vec::sub(const Vec *a, const Vec *b) {
        return sub(const_cast<Vec*>(view->at), const_cast<Vec*>(view->from));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these two pointers, amen and ptr , where all the values i
I have two pointers, char *str1; int *str2; If I look at the size
I have two unmanaged pointers in the form of IntPtr and want to copy
I have a class A containing two pointers to objects of another class B.
I have need for a function pointer that takes two arguments and returns a
I have two application that need to talk to each other. App1 needs to
I have two questions related to function objects and function pointers, Question : 1
I have code very similiar to this: LINT_rep::Iterator::difference_type LINT_rep::Iterator::operator+(const Iterator& right)const { return (this
Have a homework assignment in which I'm supposed to create a vector of pointers
I have class with two fields witch are pointers to abstract class. How i

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.