I am getting an error line 5 of filesys about passing 'const Filesys' as 'this' argument of std:string Sdrive I am not able to see why looks like it is passing correctly to me. Any help would be greatly appreciated.
#ifndef FILESYS_H
#define FILESYS_H
#include<iostream>
#include<string>
#include<fstream>
#include<sstream>
#include<vector>
//#include"Shell.h"
#include"Sdrive.h"
usingnamespace std;
class Filesys: public Sdrive
{
private:
int rootsize; //maximum number of entries in ROOT
int fatsize; //number of blocks occupied by FAT
vector<string> filenames; // filenames in root
vector<int> firstblock; // firstblocks in ROOT
vector<int> fat; // File Allocation Table
public:
Filesys( string filename); //creates an Sdrive
int fsclose(); //
int fssyncout (); //
void buildfilenames(); //
void buildfat(); //
int newfile (string file); //
int rmfile (string file);//
int getfirstblock(string file);//
int addblock (string file , string block);//
int delblock(string file , int blocknumber);
int readblock(string file , int blocknumber,string buffer);
int writeblock (string file , int blocknumber , string buffer);
int nextblock(string file , int blocknumber) ;
int getrootsize(); //
int getfatsize(); //
int getblocksize()const; //
string getdiskname() const; //
bool fileinroot(string file);//
vector<string> block(string s , int i);//
bool blockinfile(string s, int i);//
void display();
};
string Filesys::getdiskname() const
{
string temp = Sdrive::getname();
return temp;
}
Sdrive Class
1 2 3 4 5 6 7 8 9 10 11 12 13
class Sdrive {
public:
//Sdrive ( string diskname );
Sdrive ( string diskname , int numberofblocks , int blocksize );
int getblock( int blocknumber , string& buffer);
int putblock( int blocknumber , string buffer);
string getname() {return diskname;}
int getblocksize() { return blocksize;}
private:
string diskname; //file name of software disk
int numberofblocks; //number of blocks on disk
int blocksize; //block size in bytes
};
Ah gotcha, thank you but I am still getting an error in that section lines 56 says no matching function for call to Sdrive::Sdrive(std::string&)? I appreciate it.
I can't see that call in the above code, but I presume you do not have an overloaded constructor that only takes in a string as parameter. Post your new code.
getname is the name of a function. Did you mean to actually call the function? I think you really do want filename there though, as calling Sdrive's method won't be useful since it hasn't even been constructed yet.