G
Gary Wessle
Hi
I have been trying to find out the reason for this error for an 1hr,
please look at it for me.
thanks
**************** error ****************
$ make; ./proj
g++ -gdwarf-2 -c -o gen_data.o gen_data.cpp
gen_data.cpp: In member function 'void gen_data::gen_mngr()':
gen_data.cpp:31: error: expected primary-expression before ')' token
gen_data.cpp:32: error: expected primary-expression before '->' token
gen_data.cpp:32: error: expected primary-expression before '->' token
gen_data.cpp: At global scope:
gen_data.cpp:40: error: default argument given for parameter 2 of 'void gen_data:nce_gen(std::string, double)'
gen_data.h:17: error: after previous specification in 'void gen_data:nce_gen(std::string, double)'
make: *** [gen_data.o] Error 1
**************** gen_data.h ****************
#ifndef GEN_DATA_H
#define GEN_DATA_H
#include <string>
using std::string;
#include <map>
using std::map;
class gen_data
{
const map<string,double> cur_pairs;
string parent_dir;
void gen_mngr();
void once_gen(string, double val=99);
public:
gen_data(const map<string,double>&);
~gen_data();
};
#endif
**************** gen_data.cpp ****************
#include <string>
using std::string;
#include <iostream>
using std::cout;
using std::endl;
#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
#include "boost/filesystem/fstream.hpp" // ditto
#include "gen_data.h"
namespace fs = boost::filesystem;
gen_data::~gen_data(){}
gen_data::gen_data(const map<string,double> & m)
arent_dir("../data"), cur_pairs(m)
{
gen_mngr();
}
void gen_data::gen_mngr(){
fs:ath data_dir(parent_dir);
if (!exists(data_dir))//needs an excption handler
cout << parent_dir << " does not exist" << endl;
if (cur_pairs.size()==0){
fs::directory_iterator end_iter;
for(fs::directory_iterator dir_itr(parent_dir); dir_itr != end_iter; ++dir_itr )
once_gen(dir_itr->leaf());
} else {
typedef map<string,double>::const_iterator mi;
for (mi p = cur_pairs.begin(); p != cur_pairs.end(); ++mi)
once_gen(mi->first, mi->second);
}
}
void gen_data:nce_gen(string cur_p, double val=99){
cout << cur_p << endl;
}
**************** main.cpp ****************
#include <string>
using std::string;
#include <map>
using std::map;
#include "gen_data.h"
int main(){
map <string,double> m;
m["mothers"]=3;
gen_data gen_job(m);
}
I have been trying to find out the reason for this error for an 1hr,
please look at it for me.
thanks
**************** error ****************
$ make; ./proj
g++ -gdwarf-2 -c -o gen_data.o gen_data.cpp
gen_data.cpp: In member function 'void gen_data::gen_mngr()':
gen_data.cpp:31: error: expected primary-expression before ')' token
gen_data.cpp:32: error: expected primary-expression before '->' token
gen_data.cpp:32: error: expected primary-expression before '->' token
gen_data.cpp: At global scope:
gen_data.cpp:40: error: default argument given for parameter 2 of 'void gen_data:nce_gen(std::string, double)'
gen_data.h:17: error: after previous specification in 'void gen_data:nce_gen(std::string, double)'
make: *** [gen_data.o] Error 1
**************** gen_data.h ****************
#ifndef GEN_DATA_H
#define GEN_DATA_H
#include <string>
using std::string;
#include <map>
using std::map;
class gen_data
{
const map<string,double> cur_pairs;
string parent_dir;
void gen_mngr();
void once_gen(string, double val=99);
public:
gen_data(const map<string,double>&);
~gen_data();
};
#endif
**************** gen_data.cpp ****************
#include <string>
using std::string;
#include <iostream>
using std::cout;
using std::endl;
#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
#include "boost/filesystem/fstream.hpp" // ditto
#include "gen_data.h"
namespace fs = boost::filesystem;
gen_data::~gen_data(){}
gen_data::gen_data(const map<string,double> & m)
arent_dir("../data"), cur_pairs(m)
{
gen_mngr();
}
void gen_data::gen_mngr(){
fs:ath data_dir(parent_dir);
if (!exists(data_dir))//needs an excption handler
cout << parent_dir << " does not exist" << endl;
if (cur_pairs.size()==0){
fs::directory_iterator end_iter;
for(fs::directory_iterator dir_itr(parent_dir); dir_itr != end_iter; ++dir_itr )
once_gen(dir_itr->leaf());
} else {
typedef map<string,double>::const_iterator mi;
for (mi p = cur_pairs.begin(); p != cur_pairs.end(); ++mi)
once_gen(mi->first, mi->second);
}
}
void gen_data:nce_gen(string cur_p, double val=99){
cout << cur_p << endl;
}
**************** main.cpp ****************
#include <string>
using std::string;
#include <map>
using std::map;
#include "gen_data.h"
int main(){
map <string,double> m;
m["mothers"]=3;
gen_data gen_job(m);
}