博客來網路書店查詢

書名

博客來網路書店查詢

星期五, 5月 20, 2016

關於this

class部分
class Box
{
   public:
      Box(double l=2.0, double b=2.0, double h=2.0)
      {
         cout <<"建立物件" << endl;
         length = l;
         breadth = b;
         height = h;
      }
      double Volume()
      {
         return length * breadth * height;
      }
      int compare(Box box)
      {
         return this->Volume() > box.Volume();
      }
   private:
      double length;     
      double breadth;     
      double height;     
};
 
程式流程
 
   Box Box1(3.3, 1.2, 1.5);    
   Box Box2(8.5, 6.0, 2.0);    

   if(Box1.compare(Box2))
   {
      cout << "Box2 小於 Box1" <<endl;
   }
   else
   {
      cout << "Box2 大於等於 Box1" <<endl;
   } 

星期二, 4月 19, 2016

voctor中包含的函數用法

c.assign(beg,end)c.assign(n,elem)    將[beg; end)區間中的資料傳送資料給c。將n個elem的資料傳送資料給c。
c.at(idx)    傳回索引idx所指的資料,如果idx超越索引上限,拋出out_of_range。
c.back()    傳回最後一個資料,不檢查這個資料是否存在。
c.begin()   傳回vector中的第一個資料位址。
c.end()        指向vector中末端元素的下一個,指向一個不存在元素。
c.capacity()    返回vector中資料個數。
c.max_size()   返回vector中最大資料的數量。
c.size()    返回vector中實際資料的個數。
c.empty()    判斷vector是否為空。
c.erase(pos) 刪除pos位置的資料,傳回下一個資料的位置。
c.erase(beg,end) 刪除[beg,end)區間的資料,傳回下一個資料的位置。
c.clear()     移除vector中所有資料。
c.front()    傳回第一個資料。
get_allocator    使用構造函數返回一個資料。
c.insert(pos,elem) 在pos位置插入一個elem資料,傳回新資料位置。
c.insert(pos,n,elem)  在pos位置插入n個elem資料。無返回值。
c.insert(pos,beg,end)    在pos位置插入在[beg,end)區間的資料。無返回值。
c.pop_back()    刪除最後一個資料。
c.push_back(elem)    在尾部加入一個資料。
c.rbegin()    傳回一個逆向隊列的第一個資料。
c.rend()    傳回一個逆向隊列的最後一個資料的下一個位置。
c.resize(num)    重新指定隊列的長度。
c.reserve()    保留適當的容量。
c1.swap(c2) 與  swap(c1,c2)    將c1和c2元素互換。同一個操作。
vector          創建一個空的vector。
cvector c1(c2)  複製一個vector。
vector c(n)  創建一個vector,含有n個資料。
ector c(n, elem) 創建一個含有n個elem資料的vector。
vector c(beg,end) 創建一個以[beg;end)區間的vector。
c.~ vector ()    銷毀所有資料,釋放內存。
operator[]    返回vector中指定位置的一個引用。

星期二, 3月 22, 2016

Windows Azure的mysql與python

因為Windows Azure註冊出了問題,目前我還沒測試。
網路上查到的
Windows Azure的mysql連結參數:

db = MySQLdb.connect(host= "windows azure url goes here",user="uname",passwd="pwd",db="dbname")

不過 Pythone所提供的mysql連結參數:
db = MySQLdb.connect(host= "host","uname","pwd","dbname")


這語法得再查證,不過除了連結資料庫不同外,Windows Azure的mysql還得做以下兩件事情
1.防火牆上開啟3306
2.針對你的資料庫設定一個連線帳號,例如
 GRANT ALL ON SOMEDATABASE.* TO USERNAME@% IDENTIFIED BY 'SOMEPASSWORD'

python新增與查詢的參考語法
import MySQLdb

# Open database connection
db = MySQLdb.connect("localhost","testuser","test123","TESTDB" )

# prepare a cursor object using cursor() method
cursor = db.cursor()

# Select qSQL with id=4.
cursor.execute("SELECT qSQL FROM TBLTEST WHERE id = 4")

# Fetch a single row using fetchone() method.
results = cursor.fetchone()

qSQL = results[0]

cursor.execute(qSQL)

# Fetch all the rows in a list of lists.
qSQLresults = cursor.fetchall()
for row in qSQLresults:
    id = row[0]
    city = row[1]

    #SQL query to INSERT a record into the table FACTRESTTBL.
    cursor.execute('''INSERT into FACTRESTTBL (id, city)
                  values (%s, %s)''',
                  (id, city))

    # Commit your changes in the database
    db.commit()

# disconnect from server
db.close()


MySQL與python可參考:
http://www.tutorialspoint.com/python/python_database_access.htm

星期三, 2月 24, 2016

好像新版的CodeBlocks於Win7環境內會有問題?

好像新版的CodeBlocks於Win7環境內會有問題,我其實都沒碰過,但有非常多的朋友反映...
如果13版無法使用,那就改用12版吧~ 於C/C++編輯編譯其實是一樣的...https://sourceforge.net/projects/codeblocks/files/Binaries/12.11/Windows/