坑一:
typedef struct _st
st;st *test = (st *)malloc(sizeof(st));
st->m1 = "hello";
除錯這段**,你會發現最後一句報段錯誤。為什麼呢?string本質是個類,而malloc不知道要呼叫string的建構函式去例項化m1,結果導致m1這個物件實際不存在,去用它當然錯誤。解決這一問題的方法是使用new來建立結構體:
st *test = new st; 或 st *test =new st();
new會懂得呼叫string的建構函式去例項m1。話說為什麼能用new來建立結構體呢?因為在c++中,結構體就是特殊的類。
String 那些事兒
string byte之間的轉換 string byte byte b string str new string b byte string string str byte b str.getbyte string 與inputstream之間的轉換 string inputstream stri...
UITextView的那些坑
坑1 ios7及以上的版本上,uitextview出現這樣的問題 彈出鍵盤時,沒輸入任何文字,但是游標位置不是在最上方。解決方案 ios7以後新增了乙個屬性automaticallyadjustsscrollviewinsets,將其置為no即可。別忘了加版本判斷。if ios7 and later...
Flask SQLALCHEMY 的那些坑!!!
if request.method get 接收前段傳遞過來的使用者id uid request.args id 根據id將對應的使用者資訊讀取出來 user db.session.query users filter by id uid first print user user user1 db...