コード例 #1
0
ファイル: savingAccountTest.cpp プロジェクト: zcgu/C-_4
void savingAccountTest()
{
    SavingAccount saver1(0.03, 2000, "zhangsan");
    SavingAccount saver2(0.03, 3000, "lisi");

    saver1.print();
    saver2.print();
    cout <<endl;

    saver1.annualInterestRate=0.04;
    cout<<"改变年利率至0.04"<<endl;
    saver1.print();
    saver2.print();

}
コード例 #2
0
ファイル: text-file-saver.cpp プロジェクト: gang-chen/samoyed
int main()
{
    g_type_init();

    Samoyed::Scheduler scheduler(2);

    char *pwd = g_get_current_dir();

    std::string fileName1(pwd);
    fileName1 += G_DIR_SEPARATOR_S "text-file-saver-test.GBK";
    char *uri1 = g_filename_to_uri(fileName1.c_str(), NULL, NULL);
    if (!uri1)
    {
        printf("File name to URI conversion error.\n");
        return -1;
    }
    boost::shared_ptr<char> textUtf8(g_strdup(TEXT_UTF8), g_free);
    boost::shared_ptr<Samoyed::TextFileSaver> saver1(
        new Samoyed::TextFileSaver(scheduler, 1, uri1, textUtf8, -1,
                                   "GBK"));
    saver1->addFinishedCallback(onDone);
    saver1->addCanceledCallback(onDone);
    g_free(uri1);

    std::string fileName2(pwd);
    fileName2 += G_DIR_SEPARATOR_S "text-file-saver-test.UTF-8";
    char *uri2 = g_filename_to_uri(fileName2.c_str(), NULL, NULL);
    if (!uri2)
    {
        printf("File name to URI conversion error.\n");
        return -1;
    }
    boost::shared_ptr<Samoyed::TextFileSaver> saver2(
        new Samoyed::TextFileSaver(scheduler, 1, uri2, textUtf8, -1,
                                   "UTF-8"));
    saver2->addFinishedCallback(onDone);
    saver2->addCanceledCallback(onDone);
    g_free(uri2);

    saver1->submit(saver1);
    saver2->submit(saver2);
    scheduler.wait();

    g_free(pwd);
    return 0;
}