ISO C++ forbids declaration of 'begin' with no type

i have found another thread with this title, but it doesnt give me any clear answer, se here i am :stuck_out_tongue:

i am rolling out my own library in order to interface in a simple way with a custoim display that i made (nothing fancy, just a couple of 595).

my problem is that i have written my library and tested it on a uno, but now im trying to run it on a custom board wich implements a atmega 1284P, and it doesnt work anymore.

while i compile it it give me this error: "ISO C++ forbids declaration of 'begin' with no type [-fpermissive]". im using mighty core.

here is the header:

#ifndef displaySvapo_h
#define displaySvapo_h

#include "Arduino.h"

class displaySvapo
{
  public:
    begin(byte DATA,byte CLOCK,byte LATCH,byte PWM); //constructor

    // plus a bunch of other functions and private variables

#endif

here instead there is just the type signature of the constructor in the cpp file:

displaySvapo::begin(byte DATA,byte CLOCK,byte LATCH,byte PWM) //constructor
{
    // some code
}

i dont get why it doesnt work. from the library tutorial of the arduino site it looks like the constructor it doesnt have any return type (like java, right?)

A constructor has no return type, but every other method must have.
(Hint: A constructor has the same name as the class.)

1 Like

A constructor is named like the class it is constructing, which is obviously not 'begin'.

you are right!

thanks a lot guys!