Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use ifstream &

Status
Not open for further replies.

Huskey

Vendor
Aug 23, 2002
53
GB
Hi,

I have a problem here and hope any experts out there could help. I used ODBC to import a database. This database has been successfully loaded into a new storage structure I named it as VisualTable which can essentially be perceived as a matrix with integer entries. My problem is now how to load this data stored in VisualTable? This structure with the code as follows:

VirtualTable::Load(ifstream &stream)
{
int objects;
int attributes;

//Load table.
if (!Ouput::Load(stream, objects) || !Output::Load(stream, attributes))
return false;
....
}

I used:

ifstream stream;
CDialogTable odbc(NULL);
String strQuery = odbc.tablestring;
stream.open(strQuery.GetBuffer(), ios::in | ios::nocreate);
... The compilation up to this stage does not give any problem.

However, when I start to use this:

if (!VirtualTable::Load(*stream)) {
Message::Error("Unable to open ");
return NULL;
}

I got this error:

D:\Test\MainFrm.cpp(196) : error C2100: illegal indirection
D:\Test\MainFrm.cpp(196) : error C2352: 'VirtualTable::Load' : illegal call of non-static member function
D:\Test\system/virtualtable.h(73) : see declaration of 'Load'

My database stored in the VirtualTable can not be simply fed into the LOAD function. How to bridge this gap so that I can use the load function as shown above?

Please help...............

cheers,



 
Your problem is that you're trying to call a non-static member function with the notation for static members. Depending on exactly what's going on, you either want to make Load static and keep the current syntax, or you want to create an instance of VirtualTable ("VirtualTable vt" for example) and call the load function off that object (i.e. "vt.Load(someStream)").
 
Another thing: it looks like you try to dereference your stream ("*stream"). That doesn't make much sense. You probably just want to pass stream to the load function. Since it takes a reference, it'll take care of all the indirection for you in this case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top