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_m ngr()':
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::once_ gen(std::string , double)'
gen_data.h:17: error: after previous specification in 'void gen_data::once_ 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,doub lecur_pairs;
string parent_dir;
void gen_mngr();
void once_gen(string , double val=99);
public:
gen_data(const map<string,doub le>&);
~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::filesyst em;
gen_data::~gen_ data(){}
gen_data::gen_d ata(const map<string,doub le& m)
:parent_dir("../data"), cur_pairs(m)
{
gen_mngr();
}
void gen_data::gen_m ngr(){
fs::path data_dir(parent _dir);
if (!exists(data_d ir))//needs an excption handler
cout << parent_dir << " does not exist" << endl;
if (cur_pairs.size ()==0){
fs::directory_i terator end_iter;
for(fs::directo ry_iterator dir_itr(parent_ dir); dir_itr != end_iter; ++dir_itr )
once_gen(dir_it r->leaf());
} else {
typedef map<string,doub le>::const_iter ator mi;
for (mi p = cur_pairs.begin (); p != cur_pairs.end() ; ++mi)
once_gen(mi->first, mi->second);
}
}
void gen_data::once_ 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,doublem ;
m["mothers"]=3;
gen_data gen_job(m);
}