Hello,
I have a class Pdisk
class Pdisk
{
public :
Pdisk(string diskname, int numberofblocks, int blocksize);
private :
string diskname;
int numberofblocks;
int blocksize;
};
Now I want to make a class filesys which can access an object of class Pdisk. I am not sure how to pass this object.
filesys.h:
class fileSys{
public:
Filesys(Pdisk& disk);
private:
Pdisk disk;
};
filesys.cpp file:
Filesys::Filesys(Pdisk& disk){//...}
In my driver program I want to call
Pdisk disk("disk",64,128);
fileSys fsys(disk);
I am using Visual C++ and get the error that there is no default constructor. The only constructor for Pdisk I have is the one I pasted here. Can someone explain to me how this works.
What I understand is that I have an existing object of class pdisk that I pass to the constructor of the class filesys. Since the Pdisk disk already exists I do not want to call the Pdisk constructor anymore. So I only pass the object by reference.
I do not understand the error message or how the call would be correct.
Thanks for any help!