titeuf8722
Messages postés16Date d'inscriptionmardi 25 avril 2006StatutMembreDernière intervention 7 août 2007
-
25 avril 2006 à 12:19
titeuf8722
Messages postés16Date d'inscriptionmardi 25 avril 2006StatutMembreDernière intervention 7 août 2007
-
25 avril 2006 à 13:51
Bonjour j'ai un problème pour déclarer une variable m_fich de type ofstream. Je dois la déclarer dans ma classe CProjetprofApp pour l'utiliser pour ecrire dans un fichier.
Voici le bout de programme ou j'ai déclarer les variables :
// projetprof.h : main header file for the PROJETPROF application
//
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CProjetprofApp:
// See projetprof.cpp for the implementation of this class
//
class CProjetprofApp : public CWinApp
{
public:
bool m_estOuvert;
ofstream m_fich ;//declaration de la variable
CProjetprofApp();
//{{AFX_MSG(CProjetprofApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
Mon problème c'est qu'il faut mettre un include qui est celui ci (#include <fstream>) mais je ne sais pas ou il faut le déclarer.Il doit falloir le déclarer dans cette partie de programme mais je ne c'est pas ou exactement :
Partie du programe ou il faut déclarer le include :
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
Pouvez vous m'indiquer la ligne car j'ai essayé partout mais cela me génère des erreurs du type :
c:\documents and settings\julien\bureau\projetprof\projetprof.h(27) : error C2146: syntax error : missing ';' before identifier 'm_fich'
c:\documents and settings\julien\bureau\projetprof\projetprof.h(27) : error C2501: 'ofstream' : missing storage-class or type specifiers
c:\documents and settings\julien\bureau\projetprof\projetprof.h(27) : error C2501: 'm_fich' : missing storage-class or type specifiers
nightlord666
Messages postés746Date d'inscriptionvendredi 17 juin 2005StatutMembreDernière intervention23 mai 200710 25 avril 2006 à 12:26
Il ne faut pas oublier de mettre "using namespace std;" en dessous de #include <fstream>.
Le code corrigé (seulement la partie du haut)
#if !defined(AFX_PROJETPROF_H__BA79959A_3391_450E_8C8A_2226D3E447EF__INCLUDED_)
#define AFX_PROJETPROF_H__BA79959A_3391_450E_8C8A_2226D3E447EF__INCLUDED_