I am not sure why this is occuring. I declared these functions in the header file and it is defined them in the .cpp file but in the main function it does not recognize them. Did I forget something basic or do something illegal?
The errors:
: error C3861: 'createAndInitializeTextFile': identifier not found
: error C3861: 'enterRecords': identifier not found
: error C3861: 'test': identifier not found
: error C3861: 'test': identifier not found
: error C3861: 'processChoice': identifier not found
My code for the header file:
class Tools
{
public:
Tools(int = -1, string = "", int = 0, double = 0.0);
void setPartNumber(int);
int getPartNumber() const;
void setToolName(string);
string getToolName() const;
void setInStock(int);
int getInStock() const;
void setUnitPrice(double);
double getUnitPrice() const;
void createAndInitializeTextFile();
void enterRecords();
bool test();
void processChoice();
int enterChoice();
void printTextFile(fstream&);
void updateRecord(fstream&);
void newRecord( fstream& );
void deleteRecord( fstream& );
void outputLine( ostream&, const Tools & );
int getPart( const char * const );
private:
enum Choices { PRINT = 1, UPDATE, NEW, DELETE, END };
int partNumber;
char toolName[20];
int inStock;
double unitPrice;
};
Some parts of my member function definitions:
void Tools::enterRecords()
{
fstream outTools( "hardware.dat", ios::in | ios::out | ios::binary );
// exit program if fstream cannot open file
if ( !outTools )
{
cerr << "File could not be opened." << endl;
exit( 1 );
} // end if
cout << "Enter tool identification number (1 to 100, 0 to end input)\n? ";
// require user to specify account number
Tools tool;
//cin >> partNumber;
partNumber = 3;
cout << " 3";
// user enters information, which is copied into file
while ( partNumber > 0 && partNumber <= 100 )
{
// user enters tool name, quantity and unit price
cout << "Enter the tool name, quantity in stock, and the unit price for the tool\n? ";
//cin >> setw( 20 ) >> toolName;
//cin >> inStock;
//cin >> unitPrice;
toolName = "Electric Sander";
inStock = 7;
unitPrice = 57.98;
// set the record for the part number, tool name, quantity in stock, and unit price
tool.setPartNumber( partNumber );
tool.setToolName( toolName );
tool.setInStock( inStock );
tool.setUnitPrice( unitPrice );
// seek position in file of user-specified record
outTools.seekp( ( tool.getPartNumber() - 1 ) * sizeof ( Tools ) );
// write user-specified information in file
outTools.write( reinterpret_cast < const char * >( &tool ),sizeof ( Tools) );
// enable user to enter another account
//cout << "Enter account number\n? ";
//cin >> partNumber;
} // end while
}
bool Tools::test()
{
ifstream inTools( "hardware.dat", ios::in | ios::binary );
// exit program if ifstream cannot open file
if ( !inTools )
{
cerr << "File could not be opened." << endl;
exit( 1 );
} // end if
Tools tool;
bool answer = false;
if ( tool.getPartNumber() != 0 )
answer = true;
else
answer = false;
return answer;
}
My code in .cpp main function, where the error is occurring:
#include "Tools.h"
int main()
{
createAndInitializeTextFile();
enterRecords();
test();
if(test())
{
"Hardware program successful.";
processChoice();
}
else
{
"Hardware program failed.";
}
cout << endl;
return 0;
}