Why can't the global variable delta be used in method of class?

Viewed 60

I'm a beginner of C++. In this sample, I want to use the global variable delta in method update_v() of class neuron. But it can't be used. Could you tell me why if you know?

#include<iostream>
#include<cmath>
using namespace std;

unsigned long nextt=1;
long clock=0;
long delta=0;


class neuron{
    public:
        double a,b,c,d;
        double current_v,current_u;
        double previous_v,previous_u;
        double accumulate;

        void update_v(){
            current_v=previous_v+delta(0.04*pow(previous_v,2)+previous_v)+accumulate;
        }
        void update_u(){
            current_u=previous_u+delta*a*(b*previous_v-previous_u);
        }
};
1 Answers

In void update_v(){, you do delta(0.04*pow(previous_v,2)+previous_v), so it makes the compiler thinks that you are calling a function named delta. But there's none, so it throws a error.

It looks like you forget to use the * operator:

void update_v(){
    current_v = previous_v + delta * (0.04 * pow(previous_v,2) + previous_v) + accumulate;
}
Related