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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:05:53+00:00 2026-06-10T17:05:53+00:00

I am making a GVector class that contains will further derive into 3 types

  • 0

I am making a GVector class that contains will further derive into 3 types i.e
PVector (Pixel Space Vector)
MVector (Meter Space Vector)
RVector (Rendering Space Vector)

class GVector {
  public : 
    eVectorSpace eVS; // Defines which space the vector would be
    float x,y; // The x and y values of a 2-Dimensional vector
    ...
    GVector operator+ (const GVector& v) const { return GVector(x+v.x, y+v.y, v.eVS); }
    ...
};

class MVector {
  public :
    PVector toPVector() {...}
    //Will contain functions to convert the same vector into a different space
};

I want to make it possible to add 2 vectors lying in the same space

MVector operator+ (const MVector& v) const { return MVector(x+v.x, y+v.y); }  

Do I need to make the base class function like this ?

virtual GVector* operator+ (const GVector* v) const () = 0;  

But I would like to return a vector in the same space as the two adding vectors.

The function of adding the values of the x,y are same for each type of vector.
Is there a way to minimize this into the base class itself ?
Or is there a better approach to adding vectors in the same space and converting them into different spaces ?

  • 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-10T17:05:54+00:00Added an answer on June 10, 2026 at 5:05 pm

    If it makes no sense to perform operations on two different children then the operator should not be defined on the parent. Instead a protected helper function can be defined, and then the children should implement the operator separately, delegating to the helper function.

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

Sidebar

Related Questions

Making a form that will accept a bunch of textual data and an image
Making a specific word entered into a textbox trigger a password prompt that when
Making an adobe flex ui in which data that is calculated must use proprietary
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
Making websites that appear correctly in IE is a big problem. Is there any
Making a flash page that can cycle through these three images on mouseclick. For
Making an Flex App. Just wondering if anyone has created something that fits automatically
making an Access database (2003) that is mainly used by other programmers and tech
Making a simple program which will generate a multiple choice form. I have an
Making a ruby on rails application for a class, and we are not allowed

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.