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

  • Home
  • SEARCH
  • 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 7896239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:50:34+00:00 2026-06-03T07:50:34+00:00

So I have a base class with the following header file: #ifndef ODESolver_H #define

  • 0

So I have a base class with the following header file:

#ifndef ODESolver_H
#define ODESolver_H
#endif
#include "DoublePendulum.h"

class ODESolver
{
public: 
    ODESolver(DoublePendulum &);
    virtual void Predict(const double &)=0;
    DoublePendulum DP;
};

Implementation:

#include "ODESolver.h"
#include <iomanip>

ODESolver::ODESolver(DoublePendulum &DPRef) :DP(DPRef)
{}

And a class that inherits from it:

#ifndef ODEEuler_H
#define ODEEuler_H
#endif

#include "ODESolver.h"

class ODEEuler : public ODESolver
{
public:
    ODEEuler(DoublePendulum &);
    void Predict(const double &);
};

Implementation:

#include "ODEEuler.h"

ODEEuler::ODEEuler (DoublePendulum &DPRef) :ODESolver(DPRef)
{}

void ODEEuler::Predict(const double &dt=0.005)
{
    DP=DP+DP.Derivate()*dt;
    cout << DP.getUp().getTheta() << endl;
}

The problem is that in the above implementation, DP=DP+DP.Derivate()*dt; won’t do anything. I have no clue how this is possible. I have checked if the .Derivate() member function works and it actually returns the correct values/object. On top of that, it doesn’t matter what I do there e.g. DP=DoublePendulum RandomObject(1,2,3,4) will still keep DP the same. Any ideas? I hope I provided enough information…

Also the implementation and declaration of DoublePendulum etc:

http://pastebin.com/ny3pU8aR

  • 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-03T07:50:35+00:00Added an answer on June 3, 2026 at 7:50 am

    This assignment operator

    DoublePendulum DoublePendulum::operator= (DoublePendulum &DoublePendulumA)
    {
            return DoublePendulum (DoublePendulumA);
    }
    

    creates a new value, but does not really assign anyting to the left-hand-side of the assignment. That’s why it doesn’t change!

    The standard form of assignment looks like

    DoublePendulum& DoublePendulum::operator= (const DoublePendulum& DoublePendulumA)
    {
        // assign to members of this object
    
        return *this;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following (trivially simple) base class: public class Simple { public
I have the following code: #include <iostream> #include boost/shared_ptr.hpp using boost::shared_ptr; class Base {
I have something like the following in the header class MsgBase { public: unsigned
I have a base class with the following (trimmed for brevity) declaration: public abstract
assume the following class is given: class Base{ public: Base() {} Base( const Base&
I have the following base class. public abstract class BaseEntity { public virtual long
I have a base class that has the following property: public virtual Dictionary<String, int>
We have the following class hierarchy: public class Base { public Base() { //
I have a base class like the following: [Serializable] public class SerializableDomainObject<T> { public
I have a base class that contains the following events: public event EventHandler Loading;

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.