Error by overloading the Constructor (Library)

Hi,

I'm trying to write a simple arduino library in c++

#ifndef SensorData_h
#define SensorData_h
#include <Arduino.h>

class SensorData 
{
	public:

		SensorData(char sensorType, char counter, time_t t);
		SensorData(char sensorType, char counter, int16_t i1, int16_t i2, int16_t i3);
		SensorData(char sensorType, char counter, float f);
		SensorData(char sensorType, char counter, long l);
		void print(); // 
	private:

		char _sensorMetaData;
		char _counter;
		char _data[6];	
};

#endif

But when I try to test it doing an instance of the class ...

#include <SensorData.h>

long weight = 186000L;
char sensorType = 3;
char counter = 5;
SensorData sData(sensorType, counter, weight);
    
void setup()
{

}

void loop()
{
  sData.print();
  delay(5000);
}

...... I get the following error:

In file included from .../Arduino/SensorData_Example/SensorData_Example.ino:1:0:
.../Arduino/libraries/SensorData/SensorData.h:25:3: error: 'SensorData::SensorData(char, char, long int)' cannot be overloaded
SensorData(char sensorType, char counter, long l);
^
.../Arduino/libraries/SensorData/SensorData.h:16:3: error: with 'SensorData::SensorData(char, char, time_t)'
SensorData(char sensorType, char counter, time_t t);
^
Error compilando para la tarjeta Teensy 3.2 / 3.1.

Is it not allowed to use constructor overloading in Arduino's libraries?

Or I'm doing something wrong?

Regards
Patricio

I would guess that long and time_t resolve to the same type, so the compiler cannot distinguish between the two signatures. One brute force approach is to either re-order the arguments to one of the constructors, or add an additional dummy argument, just to dis-ambiguate the signatures

Regards,
Ray L.

RayLivingston:
I would guess that long and time_t resolve to the same type, so the compiler cannot distinguish between the two signatures. One brute force approach is to either re-order the arguments to one of the constructors, or add an additional dummy argument, just to dis-ambiguate the signatures

When you have a number of constructors with different signatures, this is a sign that it's time to use static factory methods. C++ doesn't quite work like that, so I suppose some properly-named initialization methods would be the go.