这些错误意味着什么? 我对C++比较陌生,所以当我看到这些错误的模板时,我就有点呆板了。

这些错误意味着什么? 我对C++比较陌生,所以当我看到这些错误的模板时,我就有点呆板了。,c++,compiler-errors,C++,Compiler Errors,这是我的密码: #include "scene.hpp" #include <map> #include <vector> #include <string> #include <algorithm> #include <functional> // projects a ray from the eyepoint through (x, y) in the image plane Ray Camera::project_ray(in

这是我的密码:

#include "scene.hpp"
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

// projects a ray from the eyepoint through (x, y) in the image plane
Ray Camera::project_ray(int x, int y){
}

class scene_parser{
public:
  class unimplemented_exception {};
  class unknown_command_exception {};
  class malformed_command_exception {};

  scene_parser(Scene &s);
  void parse(const std::string &filename);
private:
  PixelBufferPTR current_texture;
  Colour current_material_colour;
  Material current_material;

  typedef void (scene_parser::*parsefunc )(std::vector<std::string>);
  std::map<std::string, parsefunc> funcMap;
  void init_funcMap();
  void apply_func(const std::vector<std::string> &line);

  // methods which parse the scene file
  // they each receive a line of the file, tokenized on whitespace
  void camera_from(std::vector<std::string> line);
  void camera_target(std::vector<std::string> line);
  void camera_forw(std::vector<std::string> line);
  void camera_up(std::vector<std::string> line);
  void camera_angle(std::vector<std::string> line);
  void camera_resolution(std::vector<std::string> line);

  void sphere(std::vector<std::string> line);
  void tsphere(std::vector<std::string> line);
  void texture(std::vector<std::string> line);
  void mesh(std::vector<std::string> line) {throw unimplemented_exception();}

  void background(std::vector<std::string> line);
  void ambient_light(std::vector<std::string> line);
  void parallel_light(std::vector<std::string> line);
  void point_light(std::vector<std::string> line);
  void spot_light(std::vector<std::string> line) {throw unimplemented_exception();}
  void material(std::vector<std::string> line);

  void render(std::vector<std::string> line);
  void trace_depth(std::vector<std::string> line);
};

scene_parser::scene_parser(Scene &s) : current_material_colour(0, 0, 0), current_material(0, 0, 0, 0, 0) {
  init_funcMap();
}

void scene_parser::init_funcMap(){
  funcMap["camera_from"] = &scene_parser::camera_from;
  funcMap["camera_target"] = &scene_parser::camera_target;
  funcMap["camera_forw"] = &scene_parser::camera_forw;
  funcMap["camera_up"] = &scene_parser::camera_up;
  funcMap["camera_angle"] = &scene_parser::camera_angle;
  funcMap["camera_resolution"] = &scene_parser::camera_resolution;
  funcMap["sphere"] = &scene_parser::sphere;
  funcMap["tsphere"] = &scene_parser::tsphere;
  funcMap["texture"] = &scene_parser::texture;
  funcMap["mesh"] = &scene_parser::mesh;
  funcMap["background"] = &scene_parser::background;
  funcMap["ambient_light"] = &scene_parser::ambient_light;
  funcMap["parallel_light"] = &scene_parser::parallel_light;
  funcMap["point_light"] = &scene_parser::point_light;
  funcMap["spot_light"] = &scene_parser::spot_light;
  funcMap["material"] = &scene_parser::material;
  funcMap["render"] = &scene_parser::render;
  funcMap["trace_depth"] = &scene_parser::trace_depth;
}

void scene_parser::apply_func(const std::vector<std::string> &line){
  if(line.size() != 0){
    std::map<std::string, parsefunc>::iterator it = funcMap.find(line[0]);
    if(it == funcMap.end()) throw unknown_command_exception();
    else{
      parsefunc f = it->second;
      this->*f(line); //line 86
    }
  }
}

void scene_parser::parse(const std::string &filename){
  std::vector<std::string> lines = tokenize_string(file_to_string(filename), "\n");

  std::vector<std::vector<std::string> > tokenized_lines;
  tokenized_lines.resize(lines.size());

  std::transform(lines.begin(), lines.end(), tokenized_lines.begin(), tokenized_lines.end(), std::bind2nd(std::ptr_fun(tokenize_string), std::string(" "))); //line 97

  std::for_each(tokenized_lines.begin(), tokenized_lines.end(), std::mem_fun(&scene_parser::apply_func)); //line 99
}
#包括“scene.hpp”
#包括
#包括
#包括
#包括
#包括
//将光线从视点投影到图像平面中的(x,y)
光线摄影机::投影光线(整数x,整数y){
}
类场景分析器{
公众:
类未实现_异常{};
类未知_命令_异常{};
类格式错误的_命令_异常{};
场景分析器(场景和场景);
void解析(const std::string和filename);
私人:
PixelBufferPTR当前纹理;
颜色当前\材料\颜色;
物料当前\物料;
typedef void(场景解析器::*parsefunc)(std::vector);
std::map funcMap;
void init_funcMap();
无效应用函数(常数标准::向量和线);
//解析场景文件的方法
//它们各自接收一行文件,在空白处标记
从(标准::矢量线)中删除摄像机;
无效摄影机_目标(标准::矢量线);
无效摄影机(标准::矢量线);
无效摄像机(标准::矢量线);
无效摄影机角度(标准::矢量线);
无效摄像机分辨率(标准::矢量线);
空心球(标准::矢量线);
void tsphere(标准::矢量线);
空洞纹理(标准::矢量线);
void mesh(std::vector line){throw unimplemented_exception();}
空背景(标准:矢量线);
无效环境光(标准:矢量线);
空心平行光(标准:矢量线);
空心点光(标准:矢量线);
void spot_light(std::vector line){throw unimplemented_exception();}
空洞材料(标准:矢量线);
无效渲染(标准::矢量线);
空洞迹线深度(标准:矢量线);
};
场景解析器::场景解析器(场景和s):当前材质颜色(0,0,0),当前材质(0,0,0,0){
init_funcMap();
}
void scene_parser::init_funcMap(){
funcMap[“camera_from”]=&场景分析器::camera_from;
funcMap[“摄影机\目标”]=&场景\分析器::摄影机\目标;
funcMap[“camera\u forw”]=&场景分析器::camera\u forw;
funcMap[“camera\u up”]=&场景分析器::camera\u up;
funcMap[“摄影机角度”]=&场景解析器::摄影机角度;
funcMap[“摄影机分辨率”]=&场景解析器::摄影机分辨率;
funcMap[“球体”]=&scene\u解析器::球体;
funcMap[“tsphere”]=&场景解析器::tsphere;
funcMap[“纹理”]=&场景解析器::纹理;
funcMap[“mesh”]=&场景解析器::mesh;
funcMap[“background”]=&scene\u解析器::background;
funcMap[“环境光”]=&场景光分析器::环境光;
funcMap[“平行光”]=&场景解析::平行光;
funcMap[“点光”]=&场景分析程序::点光;
funcMap[“聚光灯”]=&场景解析程序::聚光灯;
funcMap[“material”]=&scene\u解析器::material;
funcMap[“render”]=&scene\u解析器::render;
funcMap[“跟踪深度”]=&场景分析器::跟踪深度;
}
void scene_parser::apply_func(const std::vector&line){
如果(line.size()!=0){
std::map::iterator it=funcMap.find(第[0]行);
如果(it==funcMap.end())抛出未知的_命令_异常();
否则{
parsefunc f=it->second;
这个->*f(行);//第86行
}
}
}
void scene_parser::parse(const std::string和filename){
std::vector lines=tokenize_string(文件名),“\n”);
std::矢量符号化的_线;
标记化的_lines.resize(lines.size());
std::transform(lines.begin()、lines.end()、tokenized_lines.begin()、tokenized_lines.end()、std::bind2nd(std::ptr_fun(tokenize_string)、std::string(“”));//第97行
std::for_each(标记化的_line.begin()、标记化的_line.end()、std::mem_fun(&scene_parser::apply_func));//第99行
}
这是标记化字符串

std::vector<std::string> tokenize_string(const std::string &s, const std::string &split_chars);
std::vector tokenize_string(常量std::string&s,常量std::string&split_chars);
以下是错误:

Scene.cpp: In member function ‘void scene_parser::apply_func(const std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)’:
Scene.cpp:86: error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘f (...)’, e.g. ‘(... ->* f) (...)’
In file included from /usr/include/c++/4.4/bits/stl_function.h:712,
                 from /usr/include/c++/4.4/memory:66,
                 from light.hpp:4,
                 from Scene.hpp:4,
                 from Scene.cpp:1:
/usr/include/c++/4.4/backward/binders.h: At global scope:
/usr/include/c++/4.4/backward/binders.h: In instantiation of ‘std::binder2nd<std::pointer_to_binary_function<const std::string&, const std::string&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >’:
Scene.cpp:97:   instantiated from here
/usr/include/c++/4.4/backward/binders.h:152: error: ‘typename _Operation::result_type std::binder2nd<_Operation>::operator()(typename _Operation::first_argument_type&) const [with _Operation = std::pointer_to_binary_function<const std::string&, const std::string&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >]’ cannot be overloaded
/usr/include/c++/4.4/backward/binders.h:146: error: with ‘typename _Operation::result_type std::binder2nd<_Operation>::operator()(const typename _Operation::first_argument_type&) const [with _Operation = std::pointer_to_binary_function<const std::string&, const std::string&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >]’
In file included from /usr/include/c++/4.4/algorithm:62,
                 from Scene.cpp:5:
/usr/include/c++/4.4/bits/stl_algo.h: In function ‘_OIter std::transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation) [with _IIter1 = __gnu_cxx::__normal_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, _IIter2 = __gnu_cxx::__normal_iterator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >*, std::vector<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > >, _OIter = __gnu_cxx::__normal_iterator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >*, std::vector<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > >, _BinaryOperation = std::binder2nd<std::pointer_to_binary_function<const std::string&, const std::string&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >]’:
Scene.cpp:97:   instantiated from here
/usr/include/c++/4.4/bits/stl_algo.h:4741: error: no match for call to ‘(std::binder2nd<std::pointer_to_binary_function<const std::string&, const std::string&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >) (std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)’
/usr/include/c++/4.4/backward/binders.h:146: note: candidates are: typename _Operation::result_type std::binder2nd<_Operation>::operator()(const typename _Operation::first_argument_type&) const [with _Operation = std::pointer_to_binary_function<const std::string&, const std::string&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >]
/usr/include/c++/4.4/bits/stl_algo.h: In function ‘_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter = __gnu_cxx::__normal_iterator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >*, std::vector<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > >, _Funct = std::mem_fun1_t<void, scene_parser, const std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&>]’:
Scene.cpp:99:   instantiated from here
/usr/include/c++/4.4/bits/stl_algo.h:4200: error: no match for call to ‘(std::mem_fun1_t<void, scene_parser, const std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&>) (std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)’
/usr/include/c++/4.4/bits/stl_function.h:604: note: candidates are: _Ret std::mem_fun1_t<_Ret, _Tp, _Arg>::operator()(_Tp*, _Arg) const [with _Ret = void, _Tp = scene_parser, _Arg = const std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&]
Scene.cpp:在成员函数“void Scene\u parser::apply\u func(const std::vector&)”中:
Scene.cpp:86:错误:必须使用“.*”或“->*”调用指向“f(…)”中成员函数的指针,例如“(…->*f)(…)”
在/usr/include/c++/4.4/bits/stl_function.h:712中包含的文件中,
从/usr/include/c++/4.4/memory:66,
从光照。hpp:4,
来自现场。hpp:4,
来自场景。cpp:1:
/usr/include/c++/4.4/backward/binders.h:在全局范围内:
/usr/include/c++/4.4/backward/binders.h:在“std::binder2nd”的实例化中:
Scene.cpp:97:从此处实例化
/usr/include/c++/4.4/backward/binders.h:152:错误:'typename\u Operation::result\u type std::binder2nd::operator()
/usr/include/c++/4.4/backward/binders.h:146:error:with'typename\u Operation::result\u type std::binder2nd::operator()
在/usr/include/c++/4.4/algorithm:62中包含的文件中,
来自场景。cpp:5:
/usr/include/c++/4.4/bits/stl_algo.h:在函数“\u iiter std::transform(\u iiter 1,\u iiter 1,\u iiter 2,\u iiter,\u iiter,\u BinaryOperation)[with iiter 1=\u gnu cxx::\u normal iterator,\u iiter 2=\u gnu cxx:\u gnu normal BinaryOperation
Scene.cpp:97:从此处实例化
/usr/include/c++/4.4/bits/stl_algo.h:4741:错误:调用“(std::binder2nd)(std::basic_string&,std::vector&)不匹配
/usr/include/c++/4.4/backward/binders.h:146:注:候选项为:typename\u Operation::result\u type std::binder2nd::operator()
/usr/include/c++/4.4/bits/stl_algo.h:在函数“\u Funct std::for_each(\u IIter,\u IIter,\u Funct,\u Funct)[with _IIter=\u gnu cxx::\u normal\u迭代器,\u Funct std::mem\u fun1\u t]”中:
Scene.cpp:99:从此处实例化
/usr/include/c++/4.4/bits/stl_algo.h:4200:错误:调用(std::mem_fun1_t)(std::vector&)不匹配
/usr/include/c++/4.4/bits/stl_function.h:604:注:候选函数为:_retstd::mem
Scene.cpp: In member function ‘void scene_parser::apply_func(const std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)’:
Scene.cpp:86: error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘f (...)’, e.g. ‘(... ->* f) (...)’
void scene_parser::apply_func(const std::vector<std::string> &line) {
  if (line.size() != 0) {
    std::map<std::string, parsefunc>::iterator it = funcMap.find(line[0]);
    if (it == funcMap.end()) throw unknown_command_exception();
    else {
      parsefunc f = it->second;
      (this->*f)(line);  // line 86 (fixed)
    }
  }
}
std::vector<std::vector<std::string> > tokenized_lines;
tokenized_lines.reserve(lines.size());
// c++0x: for (auto const &x : lines) {
for (std::vector<std::string>::const_iterator x = lines.begin(); x != lines.end(); ++x) {
  tokenized_lines.push_back(tokenize_string(*x), " ");  // no dereference in 0x
  tokenized_lines.back().apply_func();
}