This question already has an answer here:
I have these files:
pi_utilities.h
#ifndef UTILITIES_H_
#define UTILITIES_H_
#include "pi_dfa.h"
struct ir_statistical_measures
{
// True positive, and so on.
int tp = 0;
int tn = 0;
int fp = 0;
int fn = 0;
int dim_positive=0;
int dim_negative=0;
double accuracy = 0; //(number in [0 1])
double precision = 0;
double recall = 0;
double f_measure = 0;
double matthews = 0;
double specificity = 0; //this is recall- or true negative rate
double bcr = 0;
};
void compute_ir_stats(const pi::dfa* dfa1 ,const pi::dfa* target,const set<vector<MYTYPE>> &test_set,ir_statistical_measures &stats);
#endif
pi_utilities.cpp
#include "pi_utilities.h"
void compute_ir_stats(const pi::dfa* dfa1 ,const pi::dfa* target,const set<vector<MYTYPE>> &test_set,ir_statistical_measures &stats)
{
}
pi_dfa.h
#ifndef DFA_H_
#define DFA_H_
#include <string>
#include <vector>
#include <set>
#include "pi_utilities.h"
typedef unsigned short int MYTYPE;
using namespace std;
extern struct ir_statistical_measures &stats; //I say to compiler that definition isn't here
namespace pi
{
class dfa
{
public:
bool compare_dfa(const dfa *dfa_to_compare,string method,ir_statistical_measures &stats1,ir_statistical_measures &stats2) const;
};
}
#endif
pi_dfa.cpp
#include "pi_dfa.h"
bool pi::dfa::compare_dfa(const dfa *dfa_to_compare , string method , ir_statistical_measures &stats1 , ir_statistical_measures &stats2) const
{
set<vector<MYTYPE>> test_set;
compute_ir_stats(dfa_to_compare,this,test_set,stats1);
return true;
}
main.cpp
#include "pi_dfa.h"
int main()
{
pi::dfa* L_dfa=NULL;
L_dfa = new pi::dfa();
pi::dfa* O_dfa=new pi::dfa();
bool value_return;
struct ir_statistical_measures test_set_ir_statistical_measures; //struct defined in pi_utilities.h
struct ir_statistical_measures test_set_ir_statistical_measures2;
value_return = L_dfa->compare_dfa(O_dfa,"method",test_set_ir_statistical_measures,test_set_ir_statistical_measures2);
}
I would call from a function of a class a global method. This method has a struct defined in the "global space" and this rason bring me to include an extern declaration in pi_dfa.h for the struct: I don't know if it's right. Furthermore the called global function has a pointer to a member of the class dfa. But i get these compile errors:
pi_utilities.h:27:29: error: ‘pi’ does not name a type
void compute_ir_stats(const pi::dfa* dfa1 ,const pi::dfa* target,const set<vector<MYTYPE>> &test_set,ir_statistical_measures &stats);
^
pi_utilities.h:27:36: error: expected unqualified-id before ‘*’ token
void compute_ir_stats(const pi::dfa* dfa1 ,const pi::dfa* target,const set<vector<MYTYPE>> &test_set,ir_statistical_measures &stats);
^
pi_utilities.h:27:36: error: expected ‘)’ before ‘*’ token
pi_utilities.h:27:36: error: expected initializer before ‘*’ token
pi_dfa.cpp: In member function ‘bool pi::dfa::compare_dfa(const pi::dfa*, std::string, ir_statistical_measures&, ir_statistical_measures&) const’:
pi_dfa.cpp:8:56: error: ‘compute_ir_stats’ was not declared in this scope
compute_ir_stats(dfa_to_compare,this,test_set,stats1);
^
In file included from pi_dfa.h:8:0,
from main.cpp:1:
pi_utilities.h:27:29: error: ‘pi’ does not name a type
void compute_ir_stats(const pi::dfa* dfa1 ,const pi::dfa* target,const set<vector<MYTYPE>> &test_set,ir_statistical_measures &stats);
^
pi_utilities.h:27:36: error: expected unqualified-id before ‘*’ token
void compute_ir_stats(const pi::dfa* dfa1 ,const pi::dfa* target,const set<vector<MYTYPE>> &test_set,ir_statistical_measures &stats);
^
pi_utilities.h:27:36: error: expected ‘)’ before ‘*’ token
pi_utilities.h:27:36: error: expected initializer before ‘*’ token
Maybe there is a namespace problem or other. I made some attemps but I was not able to fix problems and compile. How could I fix it?
I'm using C++11 (The code here is rearranged to a minimal executable version)
Aucun commentaire:
Enregistrer un commentaire