c++ - Forward Declaration of Class: Syntax Error -


i'm getting declaration syntax error in following code:

fileio.h

class fileio;  //error here: i'm trying declare can use in read() function int read(char* file_1);   //file read function 

fileio.cpp

int read(char* file_1) {   //file read function     fileio object_1;     int records_read=0;     ifstream fin;     fin.open(file_1, ios::binary);   //opens file again      while(fin.read((char*)& object_1, sizeof(object_1))) {          records_read++;         object_1.show_tablular();     }     fin.close();     return records_read; } 

test.cpp

template <class t> void addcolumn(t data, const int& width) {     cout<<setw(width)<<data<<" | "; }  void test_class::show_tablular() {     cout<<endl; addcolumn(record_id,7); addcolumn(char_member, 20); addcolumn(int_member, 11); addcolumn(float_member, 13); } 

inside main()

 class fileio : public test_class {   //trying relate 2 classes   public:      void show_tablular() {          test_class::show_tablular();       } }; 

i don't understand why it's happening...

forward declarations fine resolving pointer , reference types in declarations.

however, compiler needs complete definition of types when compiling functions.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -