Classes inheretance problem...

This is a discussion on Classes inheretance problem... within the C++ Programming forums, part of the General Programming Boards category; hi I have 2 files, the first one has class name pDisk the second one has a class caled pFileTable ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    249

    Classes inheretance problem...

    hi
    I have 2 files, the first one has class name pDisk

    the second one has a class caled pFileTable : public pDisk

    Please tell me what is wrong with my code:
    here is the two classes

    from File name : pDiskFile.h
    Code:
             
    
    #ifndef P_DISK_FILE_H
    #define P_DISK_FILE_H
    
    #include <sstream>
    #include <vector>
    #include <string>
    #include <strstream>
    #include <iostream>
    #include <cstdlib>
    //#include <stdlib>
    #include <iomanip>
    #include <cmath>
    #include <math.h>
    #include <time.h>
    #include "utilities.h"
    #include "fileTable.h"
    
    //fstream pDISK;
    
    class pDisk
    {
    public:
        int fDisk(int number_Of_Blocks, int block_Size, string p_Disk_Name); //  initialize disk
        int fsCreate(string p_Disk_Name);   // creats the disk after the initialization and formats disk file with filesystem
        int fsOpen(string p_Disk_Name);  // reads file system into into memory for manipulation and whatever...!
        int synch();   // synch memory data to disk file
    
        int addBlock(string file_Name, string buffer);    // add block to file with content of buffer
        int delBlock(string file_Name, int block_Number); // delete block if in file
        int firstBlock(string file_Name);   // return first block in file
        int nextBlock(string file_Name, int block_Number);// get next block in file
        int getBlock(string file_Name, int block_Number, string &buffer); // get buffer from block if in file
    
    	void printDISK();// print the information from the disk to the screen
    	string getPhysicalBlock( string file_Name, int block_Number, string & buffer);
    	        // this will get the blockSize and store it into a buffer.
    
    /*  dealing with files in the disk
    	these was eliminated after the second phase as we made a lot of changes in the
    	file table and we don't have the time to finish them
    	to be done later...
    */
        int findBlock(string file_Name, int block_Number); // Find the Block in the File_name from the Block_Number
        int addFile( string file_Name, string fileBuffer); // add the name of the file to thr root and the file buffer to the disk
        int delFile( string file_Name);  // Dellet a file from the disk
        int filePos(string p_Disk_Name); //it takes the file name and return it position in the vROOT vector.
    
    private:
        int numberOfBlocks;     // number of blocks in pdisk
        int blockSize;          // number of bytes per block
        int fatSize;            // FAT size in blocks
        string pDiskName;       // name of pdisk for file system
        int totalBlocks;      // will have the number of the total blocks
        string dataBLOCKS;  // will have all the blocks buffer as one string
        vector <int> vFAT;   // memory storage for FAT information
        //vector <Pair> vROOT; // memory storage for root information
        vector <int> vROOT; // memory storage for root information
        vector <string> vFileName;// the file Names in the root
        //vector <Pair> vBUFFER; // memory storage:Buffer of the disk, and the block number
    };// end of Class PDisk.


    the second class is from file : fileTable.h
    Code:
    #ifndef __FILE_TABLE_H
    #define __FILE_TABLE_H
    
    #include <sstream>
    #include <vector>
    #include <string>
    #include <strstream>
    #include <iostream>
    #include <cstdlib>
    //#include <stdlib>
    #include <iomanip>
    #include <cmath>
    #include <math.h>
    #include <time.h>
    
    #include "pDiskFile.h"
    #include "utilities.h"
    
    string flat_File;
    int headerBlock;
    
    class FileTable: public pDisk // OOP //^^^^^^^^^^^line34^^^ 
    {
     public:
        FileTable();
        FileTable(string flat_File);
    
        int buildFile( string input_File);
        int addRecord( string record, string buffer);
        string searchBlock( string block, int key, string value);
        int searchAll( string value);
        int Search( string key, string value, int feild);
        int fieldQuery( string qur, int field);
        void display( string find, int flag);
        void Cat();
        int lookUp();
    
        string pack( vector<string> discr, vector<int> links);
        void   unpack(string buffer, vector<string>& discR, vector<int> links);
    // from part III
    
    
        int buildRoot( vector<string> key, vector<int> blocks); // build the Tree root.
        int bTreeSearch( int node, string key);// Search the tree for a key.
        int addBTree( int node, string & key, int& block); // add a new key to the tree
        int EXTERInsert( int node, string key, int block, string & median, int & new_Block);
        int INTERinsert( int node, string key, int block, string & median, int & newBlock);
        int extDelete( int node, string key);
        int buildKeys( string input_File); // build the keys of the tree
        void metaFile( string block, int location);// the file
        void buildNewRoot( string median, int leftChild, int rightChild);
        int fixChild(int child, int sibling, string & median);
        
        
     private:
        pDisk pTableDISK; //************here is the problem**********//
        fstream fileName;
       
    
    };// Class FileTable
    the error is

    fileTable.h:34: syntax error before `;'
    fileTable.h:37: parse error before `{'
    fileTable.h:40: parse error before `)'
    fileTable.h:69: parse error before `private'
    fileTable.h:79: invalid use of undefined type `class FileTable'
    fileTable.h:36: forward declaration of `class FileTable'



    Please , I am about to give up:.... all the errors that I have in my code is "the second class can't make a variable from the first class. I don't know why....

    Thanx a lot
    C++
    The best

  2. #2
    Shadow12345
    Guest
    the three things I did to make it compile:
    1)Add #endif at the end of each header file
    2) Add using namespace std to each file
    3) change 'fstream' to either ifstream of ofstream (ifstream = input ofstream = output)

    EDIT: It still has two warnings when I do this

    fileTable.h
    Code:
    #ifndef __FILE_TABLE_H
    #define __FILE_TABLE_H
    
    #include <sstream>
    #include <vector>
    #include <string>
    #include <strstream>
    #include <iostream>
    #include <cstdlib>
    //#include <stdlib>
    #include <iomanip>
    #include <cmath>
    #include <math.h>
    #include <time.h>
    #include <fstream>
    
    #include "pDiskFile.h"
    using namespace std;
    //#include "utilities.h"
    
    string flat_File;
    int headerBlock;
    
    class FileTable: public pDisk // OOP //^^^^^^^^^^^line34^^^ 
    {
     public:
        FileTable();
        FileTable(string flat_File);
    
        int buildFile( string input_File);
        int addRecord( string record, string buffer);
        string searchBlock( string block, int key, string value);
        int searchAll( string value);
        int Search( string key, string value, int feild);
        int fieldQuery( string qur, int field);
        void display( string find, int flag);
        void Cat();
        int lookUp();
    
        string pack( vector<string> discr, vector<int> links);
        void   unpack(string buffer, vector<string>& discR, vector<int> links);
    // from part III
    
    
        int buildRoot( vector<string> key, vector<int> blocks); // build the Tree root.
        int bTreeSearch( int node, string key);// Search the tree for a key.
        int addBTree( int node, string & key, int& block); // add a new key to the tree
        int EXTERInsert( int node, string key, int block, string & median, int & new_Block);
        int INTERinsert( int node, string key, int block, string & median, int & newBlock);
        int extDelete( int node, string key);
        int buildKeys( string input_File); // build the keys of the tree
        void metaFile( string block, int location);// the file
        void buildNewRoot( string median, int leftChild, int rightChild);
        int fixChild(int child, int sibling, string & median);
        
        
     private:
        pDisk pTableDISK; //************here is the problem**********//
        ofstream fileName;
       
    
    };// Class FileTable
    #endif
    pDiskFile.h
    Code:
    #ifndef P_DISK_FILE_H
    #define P_DISK_FILE_H
    
    #include <sstream>
    #include <vector>
    #include <string>
    #include <strstream>
    #include <iostream>
    #include <cstdlib>
    //#include <stdlib>
    #include <iomanip>
    #include <cmath>
    #include <math.h>
    #include <time.h>
    //#include "utilities.h"
    #include "fileTable.h"
    using namespace std;
    //fstream pDISK;
    
    class pDisk
    {
    public:
        int fDisk(int number_Of_Blocks, int block_Size, string p_Disk_Name); //  initialize disk
        int fsCreate(string p_Disk_Name);   // creats the disk after the initialization and formats disk file with filesystem
        int fsOpen(string p_Disk_Name);  // reads file system into into memory for manipulation and whatever...!
        int synch();   // synch memory data to disk file
    
        int addBlock(string file_Name, string buffer);    // add block to file with content of buffer
        int delBlock(string file_Name, int block_Number); // delete block if in file
        int firstBlock(string file_Name);   // return first block in file
        int nextBlock(string file_Name, int block_Number);// get next block in file
        int getBlock(string file_Name, int block_Number, string &buffer); // get buffer from block if in file
    
    	void printDISK();// print the information from the disk to the screen
    	string getPhysicalBlock( string file_Name, int block_Number, string & buffer);
    	        // this will get the blockSize and store it into a buffer.
    
    /*  dealing with files in the disk
    	these was eliminated after the second phase as we made a lot of changes in the
    	file table and we don't have the time to finish them
    	to be done later...
    */
        int findBlock(string file_Name, int block_Number); // Find the Block in the File_name from the Block_Number
        int addFile( string file_Name, string fileBuffer); // add the name of the file to thr root and the file buffer to the disk
        int delFile( string file_Name);  // Dellet a file from the disk
        int filePos(string p_Disk_Name); //it takes the file name and return it position in the vROOT vector.
    
    private:
        int numberOfBlocks;     // number of blocks in pdisk
        int blockSize;          // number of bytes per block
        int fatSize;            // FAT size in blocks
        string pDiskName;       // name of pdisk for file system
        int totalBlocks;      // will have the number of the total blocks
        string dataBLOCKS;  // will have all the blocks buffer as one string
        vector <int> vFAT;   // memory storage for FAT information
        //vector <Pair> vROOT; // memory storage for root information
        vector <int> vROOT; // memory storage for root information
        vector <string> vFileName;// the file Names in the root
        //vector <Pair> vBUFFER; // memory storage:Buffer of the disk, and the block number
    };// end of Class PDisk.
    #endif
    note i blocked out utilities.h cuz i don't have that, also im developing under msvc++ 6.0

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    249

    ok...

    So many errors,

    I am about to give up


    here is all the files...
    Attached Files Attached Files
    C++
    The best

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    249

    second file

    second file
    Attached Files Attached Files
    C++
    The best

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    249

    third file

    third file
    Attached Files Attached Files
    C++
    The best

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    249

    last one

    utilites , which is very useful for everything you want...
    Attached Files Attached Files
    C++
    The best

  7. #7
    Shadow12345
    Guest
    I have it down to only a couple of errors, I went through and fixed probably 10 spelling errors so far. Put those files all in one .zip otherwise mods will delete it.

    I cannot find the following functions in any of your files (and I mean that, no prototypes, no implementations, nada)

    SearchRecord
    searchAll
    print

    those above don't exist anywhere that I can see, and I suspect there are more functions that you are calling that don't exist.

  8. #8
    Registered User
    Join Date
    Apr 2002
    Posts
    249

    You know what ..

    You are very helpful


    Thanx a million,
    I am working on these files since last Monday.

    you push me not to give up , this is a very intesting file structure project .
    anyway I will post them as one zip file as you ask me to do .
    just a minute...
    C++
    The best

  9. #9
    Shadow12345
    Guest
    hey i won't be able to reply for a while because I am on babysitting duty and i have to play board games with my sis

    be back in under an hour

  10. #10
    Registered User
    Join Date
    Apr 2002
    Posts
    249

    Thanx anyway

    here is the file with the corrections
    one file .zip

    Thanx anyway
    Attached Files Attached Files
    C++
    The best

  11. #11
    Shadow12345
    Guest
    I am looking again at this project of yours. So far I have commented out functions that do not exist. Now I am looking into your 'LNK 2001' errors. Whenever you see an error code and you don't know what it means copy the code that comes after 'error' then go to msdn.microsoft.com and search for that error code. It will give you a fairly decent description of the error.

  12. #12
    Shadow12345
    Guest
    This version has only 2 errors, it is saying "class pDisk type redefinition" for each. I am honestly not sure what is wrong at this point.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    Apr 2002
    Posts
    249

    One more day

    One more day ...
    One more challenge...

    Thanx from all my heart man...

    I am out of the town now... Once I am back, I will chick the code... There should be a way that we can fix this....


    Yesterday, my brian was over flow, and I needed to restart my system. I think I need to be away from the computer for one complate day , that was my father Advice....

    It is a challenge and I accept it.
    C++
    The best

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with classes and pointers
    By Akkernight in forum C++ Programming
    Replies: 18
    Last Post: 02-21-2009, 05:21 AM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  3. Having a problem with Classes
    By FoxTrot in forum C++ Programming
    Replies: 10
    Last Post: 09-06-2007, 07:40 PM
  4. Problem with destructors.
    By Hulag in forum C++ Programming
    Replies: 7
    Last Post: 06-11-2004, 12:30 PM
  5. problem w/ nested templatized classes
    By *ClownPimp* in forum C++ Programming
    Replies: 8
    Last Post: 10-19-2002, 07:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21