#include <iostream>
#include "SalesDB.h"
#include <string.h>
#include <fstream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
usingnamespace std;
using std::cout;
using std::endl;
using std::setprecision;
using std :: left;
using std:: right;
using std :: cerr;
using std :: ifstream;
SalesDB :: SalesDB ()
{
numSeller = 0;
}
SalesDB :: SalesDB (char* fileName)
{
ifstream inFile;
inFile.open (fileName, ios::binary);
if (!inFile)
{
cerr << "Error - unable to open accoutns file\n";
exit(-1);
}
inFile.read ((char*) this, sizeof(SalesDB));
inFile.close ();
}
void SalesDB :: print ()
{
int i;
cout << fixed << setprecision(2) << endl;
cout << "Sales Database Listing" << endl << endl;
for (i = 0; i < numSeller; i++)
{
Sellers[i].print();
cout << endl;
}
}
I have this error message:
SalesDB.cpp:46: error: request for member âprintâ in â((SalesDB*)this)->SalesDB::Sellers[i]â, which is of non-class type âcharâ
I'm new to this forum and also new to C++. The line that has the error is the one in bold. I'm not sure how to fix this. I would appreciate any help. Thank you.
usingnamespace std;
using std::cout;
using std::endl;
using std::setprecision;
using std :: left;
using std:: right;
using std :: cerr;
using std :: ifstream;
That is not needed. When you type usingnamespace std; cout, endl, cin, etc. will be ready to use. With that sentence you "load" everything under the std namespace. usingnamespace std; is ok for homework or your own test programs. But it's better to avoid those things when possible and use instead: std::cout << ... << std::endl; std::cin>>...
etc.