2016-12-15 3 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){ 
    } 
}; 

Also habe ich Schulprojekt und ich erstelle dies als eine Header-Datei in C++. aber wenn ich diesen Fehler kompiliere, kommt "Fehler C3861: 'load_now': Bezeichner nicht gefunden Zeile 92". ich verstehe nicht warum und wie man es repariert.Bezeichner nicht in einer Klasse gefunden C++

+3

'Load_now' vs' load_now'. – songyuanyao

Antwort

0

Sie haben etwas Problem in Ihrem Code. Sie haben Load_now. So

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

ersetzen durch

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

Was ist seq->get_data(inp) zurück? Ich denke, Compiler bestimmt nicht den Datentyp seq->get_data(inp).

Und Load_now nicht load_now