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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:08:11+00:00 2026-05-16T16:08:11+00:00

I’m creating a minimal circle-circle physics engine in a static library, and I’ve came

  • 0

I’m creating a minimal circle-circle physics engine in a static library, and I’ve came across a problem. I have a header file for object manipulation, one of the variables is the objects position. The position variable is declared in bpObject.h, and I have a void function, SetPosition(), that accesses the current position and sets its to the parameters specified (also declared in bpObject.h). My problem is that in the source file, I need to access the position variable (private). I can’t access it through the bpObject class, because, being a class, it won’t have the correct value when it is used as a type. So, how would I access the position variable within the class?

Thanks in advance,

Greg Treleaven

EDIT

Code for bpObject.h

#include "bpMath.h"

namespace bp
{
    class Object
    {
    private:
    static bp::Vector position;
    static bp::Vector velocity;
    static bp::Vector acceleration;
    public:
    static single restitution;
    static single radius;
    static void setPosition(single X, single Y);
    static bp::Vector getPosition();
    static void applyPosition(single X, single Y);
    static void setVelocity(single X, single Y);
    static bp::Vector getVelocity();
    static void applyVelocity(single X, single Y);
    static void setAcceleration(single X, single Y);
    static bp::Vector getAcceleration();
    static void applyAcceleration(single X, single Y);
     }
}
  • 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-16T16:08:12+00:00Added an answer on May 16, 2026 at 4:08 pm

    I’m guessing you don’t actually want all those ‘static’s in there, is your first problem (as it stands, you pretty much can only access a single object)

    Once you get rid of those, you can implement SetPosition in your source file by:

    namespace bp {
        void Object::SetPosition(single X, single Y) {
            position[0] = X; //or however your bp::Vector is implemented
            position[1] = Y;
        }
    }
    

    Yes, position is private, but when you actually define the method, you get to access the members. Is this at all what you are asking?

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

Sidebar

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.