I want to generate a unique id for my patient class, so I referred question
And the class below
class patient {
int id;
static int current_id;
patient() : id(current_id++) {}
};
int patient::current_id;
For each time executing program it is generating 'current_id' from 1 to 'n'. Here n=1,2,3,4.....
I want to generate 'current_id' uniquely, even I execute program for any number of time it should be unique.
And
I am doing a c++ project to store Customer and Product information, and I want to store it in a file.
class Customer
{
int id;
string name;
string type;
unsigned long long int PHNO;
string street,city;
unsigned int PIN;
public:
Customer(){}
friend void readdata();
};
class Product
{
int pid;
string pname,ptype;
unsigned int price;
string brand_name,suitable_for;
public:
Product(){}
friend void readdata();
};
Here I will not take 'id' or 'pid' as input but I want to generate it automatically and then it should be stored in a file.
I also referred
How can I create a guid in MFC
but I don't know how to use in above class.
Is there any way to generate unique 'current_id' ?
If anybody know answer post suitable OR modified class also.