what is different between <fstream.h> and <fstream>MS VC++

A

Armando

Hallo !

I habe some error in my programm,because i use <fstream.h>,I want to
use <fstream> but i don´t know which fonctions i must modify in my
program ?

Thanks you for your help.

Armando.
 
S

Sharad Kala

Armando said:
Hallo !

I habe some error in my programm,because i use <fstream.h>,I want to
use <fstream> but i don´t know which fonctions i must modify in my
program ?

Thanks you for your help.

What are the errors?
Are you writing 'using namespace std;' in your program?
 
A

Armando

Sharad Kala said:
What are the errors?
Are you writing 'using namespace std;' in your program?

yes i am writing 'using namespace std ;' and the errors are

error C2228: left of '.open' must have class/struct/union type
error C2228: left of '.eof' must have class/struct/union type
error C1903: unable to recover from previous error(s); stopping
compilation
Error executing cl.exe.

and my header file is here:

#ifndef _XML_H
#define _XML_H

#include<fstream>
#include<string>
using namespace std;

class XML
{
private:

ifstream fileread;
ofstream filewrite;

public:

// For reading file and inserting the key and value pairs into
XML file
static void readfile(char *infile,string key1,string
text1,string str_value,string val);

// Function for converting the function parameters into XML file
static void writeXML(char *infile,string val,char *path);

// retrieving the value
string getValue(char *infile,char *path);

};
#endif // _XML_H
 
K

Karl Heinz Buchegger

Armando said:
yes i am writing 'using namespace std ;' and the errors are

error C2228: left of '.open' must have class/struct/union type
error C2228: left of '.eof' must have class/struct/union type

those errors don't seem to be related to either the fstream header
or the ifstream header.

The error message looks like VC++ generated it. If so there is a line
number next to it. What line does it refere to?
 
D

Deming He

Armando said:
"Sharad Kala" <[email protected]> wrote in message

yes i am writing 'using namespace std ;' and the errors are

error C2228: left of '.open' must have class/struct/union type
error C2228: left of '.eof' must have class/struct/union type
error C1903: unable to recover from previous error(s); stopping
compilation
Error executing cl.exe.

and my header file is here:

#ifndef _XML_H
#define _XML_H

#include<fstream>
#include<string>
using namespace std;

class XML
private:

ifstream fileread;
ofstream filewrite;

public:

// For reading file and inserting the key and value pairs into
XML file
static void readfile(char *infile,string key1,string
text1,string str_value,string val);

// Function for converting the function parameters into XML file
static void writeXML(char *infile,string val,char *path);

// retrieving the value
string getValue(char *infile,char *path);

};
#endif // _XML_H

You probably used a pointer to an ifstream object as an ifstream object.
For example:

ifstream *pifs;
....
pifs.open("xmldata.xml");

or used a whatever object that wasn't an ifstream.
 
O

Old Wolf

I habe some error in my programm said:
yes i am writing 'using namespace std ;' and the errors are

error C2228: left of '.open' must have class/struct/union type
error C2228: left of '.eof' must have class/struct/union type
error C1903: unable to recover from previous error(s); stopping
compilation
Error executing cl.exe.

and my header file is here:

#include said:
#include<fstream>
#include<string>
(etc.)

You might find that you need
#include <istream>
and/or
#include <ostream>
too.
 
A

Armando

(etc.)

You might find that you need
#include <istream>
and/or
#include <ostream>
too.
//==============================================================================
Thanks you everybody
i am writting 2 programs in VC++ 6.0, one for XML files the header is
up i have no problem which them it is ok, and the second programm is a
dynamic table to memory some data typ is ok. but i want to put the
both pragrams together (2 classes in 1) and i don´t any code of
program and try to compile alone the xml.cpp file and i become this
errors.

Compiling...
xml.cpp
\config\xml.cpp(164) : error C2228: left of '.open' must have
class/struct/union type
config_xml_1\config\xml.cpp(167) : error C2228: left of '.eof' must
have class/struct/union type
config_xml_1\config\xml.cpp(167) : fatal error C1903: unable to
recover from previous error(s); stopping compilation
Generating Code...
Compiling...
Config.cpp
Generating Code...
Error executing cl.exe.

Config.exe - 3 error(s), 0 warning(s)
#===============================================================================
here are the errors line from the xml.cpp

the first ==> fileread.open(infile,ios::in);

the second ==> while(!fileread.eof())



#===============================================================================
here are the headers of the both programs.
#===============================================================================
#ifndef _XML_H
#define _XML_H

#include<fstream>
#include<string>
using namespace std;

class XML
{
private:

ifstream fileread;
ofstream filewrite;

public:

// For reading file and inserting the key and value pairs into
XML file
static void readfile(char *infile,string key1,string
text1,string str_value,string val);

// Function for converting the function parameters into XML file
static void writeXML(char *infile,string val,char *path);

// retrieving the value
string getValue(char *infile,char *path);


};

#endif // _XML_H

#===============================================================================
#ifndef _Config_h
#define _Config_h

#include <dynamictable.h>
#include <strings.h>

class Config {

private:

DynamicTable<String *> Values ;

String filename , path ;

public:

// StandardKonstruktor
Config();
// Konstruktor
Config (String , String);
// Desrtruktor
~Config();

// PutString -- Put a string value (true string) into the DynamicTable
char* PutString(String Key, String Value);
// void PutString(String Key, String Value);
// GetString -- Get a string value (true string) from the DynamicTable
String GetString (String Key);

// PutColor -- Put a color value into the DynamicTable
void PutInt(String key , int value);

// PutFloat -- Put a color value into the DynamicTable
void PutFloat (const char * Name, double Value);

// PutColor -- Put a color value into the DynamicTable
void PutColor (const char * Name, const COLORREF Value = 0);

// GetFloat -- Get a floating-point value from the DynamicTable
double GetFloat (String key);

// GetInt -- Get a Int value from the DynamicTable
int GetInt (String key);

// GetColor -- Get a color (COLORREF) value from the DynamicTable
COLORREF GetColor(String key);

// Save the value
void save ();

};
#endif // Config_h

#===============================================================================

THX

Armando
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top