You can initialise your member variables in a constructor by using an initialisation list, e.g.,
Code:
class patient {
private:
int name;
int id;
public:
patient(int newName, int newId) : name(newName), id(newId) {}
};
Of course, you can still do assignment if you prefer, in pretty much the same way as you would in a normal function, except that you would not declare the member variables, e.g.,
Code:
class patient {
private:
int name;
int id;
public:
patient(int newName, int newId) {
name = newName;
id = newId;
}
};
Constructor initialisation lists are usually preferred, and watch the semi-colon at the end of your class declaration.
If you are talking about how to use the constructor, then it would be as simple as:
Code:
patient sujeet1(1, 2);
Though I do not understand why you take an int for a name