2016-12-15 9 views
-5
#include <iostream> 
#include <fstream> 
#include <string> 
#include "SFML\Graphics.hpp" 
#include "Tree.h" 

template <class type> 
class loader{ 
private: 
    tree<type> *seq; 
    sf::Sprite BG_img; 
    sf::Texture texture; 
    int seq_c; 
    //node<sf::String> cp1; 
    //node<sf::String> *temp; 
    //declaring text object 
    sf::Text text; 
    sf::Text sfoption1; 
    sf::Text sfoption2; 
    sf::Text sfoption3; 
    sf::String path; 

public: 
    loader(){ 
     seq=NULL; 
     seq_c=1; 
     //setting text 
     text.setCharacterSize(15); 
     text.setColor(sf::Color::Black); 

     sfoption1.setCharacterSize(15); 
     sfoption1.setColor(sf::Color::Black); 

     sfoption2.setCharacterSize(15); 
     sfoption2.setColor(sf::Color::Black); 

     sfoption3.setCharacterSize(15); 
     sfoption3.setColor(sf::Color::Black); 

     //cp1.setData(1); 
     //cp1.setopt1(newnode(temp,1)); 
    } 
    void set_tree(tree<type> *a,int deep,sf::String Root_name="1"){ 
     seq=a; 
     add_data(seq,deep,Root_name); 
    } 

    void add_data(tree<type> *a, int counter=0, sf::String nama="1"){ 
     if(counter == 3); 
     else { 
      a->add(nama); 
      counter++; 
      add_data(a, counter, nama + ".1"); 
      add_data(a, counter, nama + ".2"); 
      add_data(a, counter, nama + ".3"); 
     } 
    } 
    int Load_now(sf::String seq='1'){ 
     path = "Sequence/" + seq +".png"; 
     texture.loadFromFile(path); 
     BG_img.setTexture(texture); 

     ifstream ff; 
     string data, option1, option2, option3; 
     string s_path = "Sequence/" + seq + ".txt"; 
     ff.open(s_path, ios::in); 
     getline(ff,data); 
     getline(ff,option1); 
     if(!ff.eof()) getline(ff,option2); 
     if(!ff.eof()) getline(ff,option3); 
     ff.close(); 


     //setting text position 
     text.setPosition(0,0); 
     sfoption1.setPosition(0,1); 
     sfoption2.setPosition(0,2); 
     sfoption3.setPosition(0,3); 

     //passing text 
     text.setString(data); 
     sfoption1.setString(option1); 
     if(option1 == "Main menu") return 0; 
     else return 1; 
     if(option2 != "") sfoption2.setString(option2); 
     if(option3 != "") sfoption3.setString(option3); 


    } 

    int next(int inp){ 
     return load_now(seq->get_data(inp)); 
    } 
    void draw(sf::RenderWindow &window){ 
     window.draw(BG_img); 
     //draW TO DISPLAY text 
     window.draw(text); 
     window.draw(sfoption1); 
     if(sfoption2 != NULL) window.draw(sfoption2); 
     if(sfoption3 != NULL) window.draw(sfoption3); 
    } 
    void chhose(int x){ 
    } 
}; 

所以我有学校项目,我创建这个作为头文件在c + +。 但我编译这个错误来了 “错误C3861:'load_now':标识符未找到第92行”。 我不明白为什么以及如何解决它。在一个类中找不到标识C++

+3

'Load_now'。 – songyuanyao

回答

0

你在你的代码稍有问题。您有Load_now。所以,

return load_now(seq->get_data(inp)); 

VS`load_now`替代由

return Load_now(seq->get_data(inp)); 
0

什么是seq->get_data(inp)返回?我认为编译器不确定seq->get_data(inp)的数据类型。

而且Load_nowload_now