const char*, extern const char*, My Custom Library

vickeyhort:
All the things such as call to connect to MQTT server will get initiated with instance of library.

in that case, how about passing the string as one of parameters of the constructor?

** side note: be sure to be mindful not to attempt to futz around with the hardware during the creation of global objects... things like setting pinMode and such.

here are some pseudo code ramblings...

#include "MyClass.h"

const char* CLIENT_ID = "someSuperSecretClientIdentification";

MyClass someInstance = MyClass(CLIENT_ID);

and then your constructor would look similar the above:

header:

#ifndef MYCLASS_H
#define MYCLASS_H

#include <Arduino.h>
#include "MQTT.h"  //example

class MyClass{
  public:
    MyClass(const char* id = nullptr);
    // ... and so on...

  private:
    const char* clientId;  // this is a pointer to an immutable char[] object...
   // ... and so on...
};


#endif

implementation:

#include "MyClass.h"
#include <Arduino.h>
#include "MQTT.h"

MyClass::MyClass(const char* id)
{
  clientId = id;
  // do some MQTT stuff, for example
  
}