function - C++ request for member (blank) in (blank) , which is of non-class type (blank) when calling method -




i'm trying learn artificial neural networks using page(it's in processing i'm converting c++ while changing minor parts): http://natureofcode.com/book/chapter-10-neural-networks/ when run code down below error:

main.cpp: in function ‘int main()’: main.cpp:36:7: error: request member ‘feedforward’ in ‘idk’, of non-class type ‘perceptron()’   idk->feedforward({1.0, .5}); 

i've looked around dont think can find gets error while calling method. code:

#include <stdio.h> #include <math.h> #include <time.h> #include <stdlib.h> #include <vector>  const double e = 2.71828182845904523536;  float s(float in){     return 1 / (1 + pow(e, -(in))); }  double frand(double fmin, double fmax){     double f = (double)rand() / rand_max;     return fmin + f * (fmax - fmin); }  struct perceptron{      perceptron(int n);     std::vector<double> weights;     int feedforward(float inputs[]); };  perceptron::perceptron (int n){     weights.assign(n, frand(-1.0, 1.0)); }  int perceptron::feedforward(float inputs[]){     return 0; // have testing can call }  int main(){     srand(time(null));      perceptron idk();     idk.feedforward({1.0, .5});      return 0; } 

perceptron idk(); declaration of function, not object. either pass constructor parameters idk or make default constructor takes no argument. code appears intended use have perceptron default ctor, should remove () idk declaration make declaration of object instead of function , remove int n perceptron constructor.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -