现在的位置: 首页 > 综合 > 正文

January 13th Tuesday 2009 (一月 十三日 火曜日)

2013年03月07日 ⁄ 综合 ⁄ 共 1293字 ⁄ 字号 评论关闭

   These days we have to work until 9 o'clock at night.  Two of our team began to learn how to implement a user interface
in Java.  Today I have to check and learn the code written by them.

  The winter still remains.  The Spring Festival is coming, it also bring us more fatigues.  After fight all day and all
night, we did not get a rest before the festival.

  Why I can choose the tried and poor vocation?

//fr.cpp
#include <unistd.h>
#include <string.h>
#include <iostream>

using namespace std;

#define MSTRING_MAX 256

class MString {
private:
        char *buf;

public:
        MString() {
                buf = new char[MSTRING_MAX];
                memset(buf, 0, sizeof(buf));
        }

        MString(char *str, int str_len) {
                buf = new char[MSTRING_MAX];
                memset(buf, 0, sizeof(buf));
                strncpy(buf, str, str_len);
        }
        ~MString() { delete buf; }

        char * getChars() { return buf; }

        friend int operator>(const MString& str1, const MString& str2);
};

int operator> (const MString& str1, const MString& str2) {
        return (strcmp(str1.buf, str2.buf) > 0) ? 1 : 0;
}

int main() {
        MString mstr1("abc", 3);
        MString mstr2("luming", 6);

        cout<<mstr1.getChars()<<endl;
        cout<<mstr2.getChars()<<endl;
        cout<<(mstr1>mstr2)<<endl;

        sleep(10000);

        return 0;
}

//const_cast<> example
const char *klingongreeting = "hello";

size_t length = strlen(const_cast<char*>(klingongreeting));

抱歉!评论已关闭.