portée des variables et utilisation bibliotheque fstream
Bonjour,
j'aimerais savoir pourquoi dans un fichier operations.cpp (en dehors du fichier contenant le main) en incluant pourtant bel et bien la bibliothèque <fstream> et en voulant initialiser une variable de la sorte:
Code:
1 2
| ofstream file;
file.open("/home/D0ppelganger/hash/hash.txt" , ios::out); |
Netbeans m'indique:
Code:
"unable to resolve identifier ofstream"
Voici l'organisation du code en gros:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| //main.cpp
#include <cstdlib>
#include <iostream>
#include "operations.h"
using namespace std;
int main(int argc, char** argv) {
//ecriture_fichier();
return 0;
} |
Code:
1 2 3 4 5 6 7
| //operations.h
#ifndef OPERATIONS_H
#define OPERATIONS_H
void ecriture_fichier();
#endif /* OPERATIONS_H */ |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| #include <iostream>
#include <fstream>
#include "operations.h"
ofstream file;
using namespace std;
//ici fonctions traitement fichier
void ecriture_fichier(ofstream file){
file.open("/home/D0ppelganger/hash/hash.txt" , ios::out);
} |
Pourtant quand j'essaie d'utiliser une autre bibliotheque, je n'ai pas de probleme avec les types et fonctions qui sont automatiquement reconnus, mais là visiblement ce n'est pas le cas...Quelqu'un sait pourquoi?