Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ FLTK Windows声明问题?筑巢太深?_C++_Window_Fltk - Fatal编程技术网

C++ FLTK Windows声明问题?筑巢太深?

C++ FLTK Windows声明问题?筑巢太深?,c++,window,fltk,C++,Window,Fltk,我在尝试使用头文件、Splash_Screen.h和record.h编译主文件时遇到问题。编译器返回“error:‘Record_window’未在此范围内声明”(在Splash_Screen.h中),查看代码时,我知道Splash_Screen.h中没有Record_window,但如果在Splash_Screen.h中键入“#include”Record.h”,则会出现“嵌套太深”错误。我现在不知道该怎么办,如果有人能帮我,我会很高兴的 闪屏。h: #包括“GUI.h” #包括“标准图书馆设

我在尝试使用头文件、Splash_Screen.h和record.h编译主文件时遇到问题。编译器返回“error:‘Record_window’未在此范围内声明”(在Splash_Screen.h中),查看代码时,我知道Splash_Screen.h中没有Record_window,但如果在Splash_Screen.h中键入“#include”Record.h”,则会出现“嵌套太深”错误。我现在不知道该怎么办,如果有人能帮我,我会很高兴的

闪屏。h:

#包括“GUI.h”
#包括“标准图书馆设施4.h”
#包括“Simple_window.h”
#包括“Graph.h”
使用名称空间图库;
结构启动屏幕:图形库::窗口{
启动屏幕(点xy、点w、点h、常量字符串和标题);
图像背景{Point{0,0},“background.jpg”};
文本{Point{210100},“团队名称”};
矩形播放{点{250380},77,20};
文字游戏{Text{Point{255395},“玩游戏”};
矩形instr_rec{Point{350380},85,20};
文字说明文字{点{355395},“说明”};
矩形高点{150380},80,20};
文字高分{Point{155395},“Highscores”};
私人:
按钮播放按钮;
按钮安装按钮;
按钮高分按钮;
int play();
int quit();
int instr();
int highscore();
};
初始屏幕::初始屏幕(点xy、整数w、整数h、常量字符串和标题)
:窗口(xy、w、h、标题),
播放按钮{点{250380},77,20,“播放”,
[](地址,地址pw){reference_to(pw).play();},
指令按钮{350380},85,20,“指令”,
[](地址,地址){reference_to(pw).instr();}},
高分按钮{点{150380},80,20,“高分”,
[](地址,地址pw){reference_to(pw).highscore();}
{
连接(播放按钮);
连接(安装按钮);
连接(highscore_按钮);
附上(背景);
ti.设置颜色(颜色:白色);
附加(ti);
播放录制设置填充颜色(颜色:白色);
附加(播放录制);
播放文字。设置颜色(颜色:黑色);
附加(播放文字);
仪器记录设置填充颜色(颜色:白色);
附(仪器记录);
仪器文本设置颜色(颜色:黑色);
附上(仪表文本);
高分辨率设置填充颜色(颜色:白色);
连接(高_rec);
高颜色文本。设置颜色(颜色:黑色);
附加(高_文本);
}
int启动屏幕::play()
{
隐藏();
返回gui_main();
}
int启动屏幕::highscore()
{
隐藏();
记录窗口赢{Point{100100},600400,“Project”};
返回gui_main();
}
int启动屏幕::instr()
{
隐藏();
简单窗口赢{Point{100100},600400,“canvas”};
返回gui_main();
}
记录。h:

#包括“GUI.h”
#包括“标准图书馆设施4.h”
#包括“Simple_window.h”
#包括“Graph.h”
#包括“Splash_Screen.h”
使用名称空间图库;
向量读取记录(){
ifstream ist{“records.txt”};
病媒记录;
字符串记录行;
而(ist>>记录行){
记录。推回(记录行);
}
退货记录;
}
矢量创建\记录\文本(矢量x){
向量返回向量;
int j=275;
int k=100;
对于(int i=0;i录制文件
\include
做什么?(我肯定有人会问我为什么我不知道;我知道,我在问你)@Jose这可能会有帮助:……还有这个:据我所知,它用文件中的任何代码替换了#include,这让我相信我可能知道解决方案。。。
#include "GUI.h"
#include "std_lib_facilities_4.h"
#include "Simple_window.h"
#include "Graph.h"

using namespace Graph_lib;


struct splash_screen : Graph_lib:: Window {
    splash_screen(Point xy, int w, int h, const string& title);

    Image background {Point{0,0},"background.jpg"};

    Text ti{Point{210,100},"Team Name"};


    Rectangle play_rec{Point{250,380},77,20};
    Text play_text{Point{255,395},"Play Game"};
    Rectangle instr_rec{Point{350,380},85,20};
    Text instr_text{Point{355,395},"Instructions"};
    Rectangle high_rec{Point{150,380},80,20};
    Text high_text{Point{155,395},"Highscores"};

private:
    Button play_button;
    Button instr_button;
    Button highscore_button;

    int play();
    int quit();
    int instr();
    int highscore();
};

splash_screen::splash_screen(Point xy, int w, int h, const string& title)
    :Window(xy,w,h,title),
    play_button{Point{250,380},77,20,"Play", 
    [](Address, Address pw) {reference_to<splash_screen>(pw).play();}},
    instr_button{Point{350,380},85,20,"Instuctions",
    [](Address, Address pw) {reference_to<splash_screen>(pw).instr();}},
    highscore_button{Point{150,380},80,20,"Highscores",
    [](Address, Address pw) {reference_to<splash_screen>(pw).highscore();}}

{
    attach(play_button);
    attach(instr_button);
    attach(highscore_button);
    attach(background);
    ti.set_color(Color::white);
    attach(ti);
    play_rec.set_fill_color(Color::white);
    attach(play_rec);
    play_text.set_color(Color::black);
    attach(play_text);
    instr_rec.set_fill_color(Color::white);
    attach(instr_rec);
    instr_text.set_color(Color::black);
    attach(instr_text);
    high_rec.set_fill_color(Color::white);
    attach(high_rec);
    high_text.set_color(Color::black);
    attach(high_text);


}

int splash_screen::play()
{
    hide();
    return gui_main();
}

int splash_screen::highscore()
{
    hide();
    Record_window win{Point{100,100},600,400,"Project"};
    return gui_main();
}

int splash_screen::instr()
{
    hide();
    Simple_window win{Point{100,100},600,400,"canvas"};
    return gui_main();
}
#include "GUI.h"
#include "std_lib_facilities_4.h"
#include "Simple_window.h"
#include "Graph.h"
#include "Splash_Screen.h"



using namespace Graph_lib;




vector<string> Read_Records(){
    ifstream ist {"records.txt"};
    vector<string> records;
    string recordLine;
    while(ist >> recordLine){
        records.push_back(recordLine);
    }
    return records;
}


vector<Text*> Create_Rec_Text(vector<string> x){
    vector<Text*> return_Vector;
    int j = 275;
    int k = 100;
    for(int i = 0; i < x.size(); i = i +2){
        if(i == 10){
            j = j - 2;
        }
        String text_String = x[i] + ' ' + x[i+1];
        Text *record = new Text(Point(j, k), text_String);
        return_Vector.push_back(record);
        k = k + 50;
    }   
    return return_Vector;
}





struct Record_window : Graph_lib::Window { 
    Record_window(Point xy, int w, int h, const string& title);
    private:
        In_box user_initials;
        Button enter_button;
        Button next_button;
        Button second_next;
        Text init_title;
        Text init_line2;
        Text title;
        void next();
        int snd_next();
        void enter();
};

Record_window::Record_window(Point xy, int w, int h, const string& title) : Graph_lib::Window{xy, w,h,title},
    next_button{Point{x_max()-70,0}, 70, 20, "Next", [ ] (Graph_lib::Address, Graph_lib::Address pw) {Graph_lib::reference_to<Record_window>(pw).next();}},
    second_next{Point{x_max()-70,0}, 70, 20, "Main Menu", [ ] (Graph_lib::Address, Graph_lib::Address pw) {Graph_lib::reference_to<Record_window>(pw).snd_next();}},
    enter_button{Point(280,210), 40, 20, "Enter", [ ] (Graph_lib::Address, Graph_lib::Address pw) {Graph_lib::reference_to<Record_window>(pw).enter();}},
    user_initials{Point(275, 190), 50, 20, "Initials:"},
    title{Point(245, 50), "Top Scores"},
    init_title{Point(225, 120), "Please enter your initials"},
    init_line2{Point(170, 135), "so it can be recorded if you beat a top score."}
{
    attach(init_title);
    attach(init_line2);
    attach(user_initials);
    attach(enter_button);
    attach(next_button);
}



void Record_window::next()
{
    detach(init_title);
    detach(init_line2);
    detach(user_initials);
    detach(enter_button);
    detach(next_button);
    title.set_font_size(24);
    attach(title);
    attach(second_next);
    vector<string> records = Read_Records();
    vector<Text*>  text_Records = Create_Rec_Text(records);
    for(int i = 0; i < text_Records.size(); i++){
        attach(*text_Records[i]);
    }
}

int Record_window::snd_next()
{
    hide(); //moves back to main menu
    splash_screen splash{Point(100, 100), 600, 400, "Main Menu"};
    return gui_main();
}

void Record_window::enter()
{
    vector<string> records = Read_Records();
    ofstream record_file;
    record_file.open("records.txt");
    for(int i = 0; i < records.size() - 2; i = i +2){
        record_file << records[i] + ' ' + records[i+1] + "   ";
    }
    String act_string = user_initials.get_string();
    record_file << act_string + ' ' + "N/A";
    record_file.close();    
}