A word of caution because from the question, I think that you don't fully grasp what is going to happen [if I am wrong then apologies].
Your code says this:
class fileSys{
public:
Filesys(Pdisk& disk);
private:
Pdisk disk;
};
And that implies that you are going to write the constructor something like this:
Filesys::Filesys(Pdisk& P) :
disk(P)
{}
OR
Filesys::Filesys(Pdisk& P)
{
disk=P;
}
I suspect from the error that you have, you wrote the second. That way TWO thinks are going to happen that you don't want.
First, you are using the compiler generated copy constructor and compiler generated assignment operator, HOWEVER you are using a class Pdisk that is not a POD [Plain old data] class (because it contains std::string which has memory management within it). Thus you are going to get strange, difficult to repeat runtime errors.
Second, you are constructing Pdisk by using a default constructor (which you have now to give) and then coping the data in. Very inefficient.
The rule of thumb is: unless you are certain that the compilers default constructor, assigment operator, copy constructor and destructor are exactly what you want write them explicitly. i.e. your class declaration should look like this:
class Pdisk
{
// stuff...
public:
Pdisk(const std::string&,int,int);
Pdisk(const Pdisk&);
Pdisk& operator=(const Pdisk&);
~Pdisk();
// more stuff....
};
If you have 1% doubt, write them. If something strange happens when using the class and you haven't written them, write them and then debug.
I also don't think that you want a default constructor for this class, based on what you have written. At least make very sure you know were in the code it is being called from.