I am trying to create separate values for each instance of an object. At this point I can give each of the 3 instances individual values for Ints, however I am not able to assign character arrays in the same way.
Ideally I would like to be able to assign separate character arrays and integers with each creation of an instance.
This is my current code
class node{
private:
int unitID;
int plantID;
int M1Thresh;
int M2Thresh;
char nodeName[15];
public:
node(int unitID, char nodeName[15], int plantID, int M1Thresh, int M2Thresh){
this->unitID = unitID;
this->plantID = plantID;
this->nodeName[15] = nodeName;
this->M1Thresh = M1Thresh;
this->M2Thresh = M2Thresh;
}
void Showit(){
// Tried this with no success also
// String outval = nodeName + "/0";
//Serial.print("Test string:");Serial.println(outval);
Serial.print("unit ID: ");Serial.println(unitID);
Serial.print("plant ID: ");Serial.println(plantID);
Serial.print("Name: "); Serial.println(nodeName[15]);
Serial.print("M1Thresh: ");Serial.println(M1Thresh);
Serial.print("M2Thresh: ");Serial.println(M2Thresh);
Serial.println(" ");
}
};
node Strawberries = node(101, "Strawberries", 01, 25, 25);
node Cucumber = node(102, "Cucumber", 02, 50, 50);
node Carrot = node (103, "Carrot", 03, 70, 70);
void setup(){
Serial.begin(9600);
}
void loop(){
Strawberries.Showit();
Cucumber.Showit();
Carrot.Showit();
delay(1000);
}
I would like to be able to create each instance with a separate char[].
My integers are sending/ assigning fine on the print out but the char[] print is giving me nothing.
Any help to point me in the right direction would me greatly appreciated.
Thanks.