1

CodeBlocks で LibXL [for C++] というサードパーティ ライブラリを使用して、Mini プロジェクトでこのコードを実行しようとしています。

#include "libxl.h"
#include <iostream>
#include<string>
#include<tchar.h>

#ifdef _UNICODE
typedef WCHAR TCHAR;
#else
typedef char TCHAR;
#endif


using namespace libxl;
using namespace std;
    //Ignore this block of comments //Specifically for CinCout 
/*
class Student_Information
{
    string First_Name, Last_Name,Mobile, Course;
    double bd_day, bd_month, bd_year,Gr_No;

   // Format* format1 = info_book->addFormat();


public:

Student_Information()
{

Book* info_book = xlCreateBook();
Sheet* sheet1 = info_book->addSheet("Sheet1");


}
    void insert_info()
    {
        int num;
        info_book->load("student_information.xls");
}*/

class Student_Information
{
    string First_Name, Last_Name,Mobile, Course;
    int bd_day, bd_month, bd_year,Gr_No;
     Book* info_book = xlCreateBook();  //Throws are warning "non-static data member initializers only available with -std=c++11 or -std=gnu++11"
    Sheet* sheet1 = info_book->addSheet("Sheet1"); //Throws the same warning even over here


public:

    void insert_info()
    {
        int num;
        info_book->load("student_information.xls");

        do
        {
            cout<<"Enter 1 to add a record | Enter 0 to exit";
            cin>>num;

            cout<<"Please enter the GR Number of the Student: ";
            cin>>Gr_No;
            sheet1->writeNum(sheet1->lastRow(),0,Gr_No);

            cout<<"Please Enter your FIRST NAME [In Capitals]: ";
            cin>>First_Name;
            sheet1->writeStr(sheet1->lastRow(),1,First_Name.c_str());

            cout<<"Please Enter your LAST NAME [In Capitals]: ";
            cin>>Last_Name;

            sheet1->writeStr(sheet1->lastRow(),2,Last_Name.c_str());

            sheet1->writeStr(sheet1->lastRow(),3,"BCA");

            cout<<"Please enter your 10 Digit mobile number: ";
            cin>>Mobile;

            sheet1->writeStr(sheet1->lastRow(),4,Mobile.c_str());

            info_book->save("student_information.xls");
        }
        while(num!=0);
       // info_book->load("student_information.xls");


       // info_book->release();

    }
};

int main()
{
    Student_Information ob1;
    ob1.insert_info();
}

コードをコンパイルしようとすると、コードで言及した 2 つの警告が表示されますが、コンパイラはエラーを表示しません

プログラムが実行されると、プログラムは 2 つのオプションを要求します。ユーザーがオプション 1 を選択すると、プログラムは GR 番号を尋ねます。GR 番号を入力すると、画面に次のメッセージが表示されてクラッシュします。

ここに画像の説明を入力

私はこのエラーについてかなり混乱しています。プロジェクトをクリーンアップして再構築しようとしましたが、役に立ちません。Encoder UTF-8 & GNU GCC COMPILER でコードブロックを使用しています。

不適切な発言をして 21 世紀のオタクの気分を害した場合は、申し訳ありません。私は LibXL にまったく慣れておらず、コーディング全般にもあまり詳しくありません。

4

1 に答える 1