C++自修入門實境秀、C++ Primer 5版研讀秀 23/ ~4.6. The Member Access Operators 漢文博士構形...





4.6. The Member Access Operators

4.6成員存取運算子

22:00(第23集)

p is a pointer, which has no members;

指標不會有成員!

箭號運算子的運算元是一個指標型別

箭號運算子產生左值(lvalue)左址右值

點運算子,如果存取成員所屬物件是左值,則傳回左值,否則就傳回右值(rvalue)。

練習4.20

vector<string>::iterator iter;

vector<string> svec{"名豈文章著?","官應老病休!"

,"飄飄何所似","天地一沙鷗"};

for (iter=svec.begin();iter!=svec.end();)

{

cout << *iter++ << endl;

}

//(a)* iter++;

52:00

可見遞增運算子是不支援string型別的

vector<string>::iterator iter;

vector<string> svec{"細草微風岸","危檣獨夜舟",

"星垂平野闊","月湧大江流",

"名豈文章著?","官應老病休!"

,"飄飄何所似","天地一沙鷗"};//https://ctext.org/library.pl?if=gb&file=77996&page=113#%E5%90%8D%E8%B1%88%E6%96%87%E7%AB%A0%E8%91%97

for (iter=svec.begin();iter!=svec.end();)

{

cout << (*iter)++ << endl;

}

//(b)(*iter)++;



Severity Code Description

Error (active) E0349 no operator "++" matches these operands

Error C2676 binary '++': 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' does not define this operator or a conversion to a type acceptable to the predefined operator

任真吟

55:20

59:50

vector<string>::iterator iter;

vector<string> svec{"細草微風岸","危檣獨夜舟",

"星垂平野闊","月湧大江流",

"名豈文章著?","官應老病休!"

,"飄飄何所似","天地一沙鷗"

,""};// https://ctext.org/library.pl?if=gb&file=77996&page=113#%E5%90%8D%E8%B1%88%E6%96%87%E7%AB%A0%E8%91%97

for (iter=svec.begin();iter!=svec.end();)

{

cout << (* iter++).empty() << endl;

}

//(c)* iter.empty()

for (iter=svec.begin();iter!=svec.end();)

{

cout << iter++->empty() << endl;

}

//(d)iter->empty();

1:21:00

for (iter=svec.begin();iter!=svec.end();++iter)

{

cout << *iter << endl;

}

//(e)++* iter;

1:22:00

//(f)iter++->empty();//已見前

1:26:10

參考: 〈Smarter Member List Filtering for C++〉https://devblogs.microsoft.com/cppblog/smarter-member-list-filtering-for-c/?fbclid=IwAR1QKf6LyDcNOCK7TASN5wqt1IKVhwWZJZ-5-kRQKF-vNI56k4VMGBfkPYE

1:37:30

As an experimental feature, Predictive IntelliSense is disabled by default, but can be enabled under Tools > Options > Text Editor > C/C++ > Experimental. Or simply type “predictive” in the (Ctrl + Q) Search Bar.

Note: If you ever wish to un–filter the completion list, just click the green “+” symbol in the bottom left of the list.



2:32:00

Visual Studio 2019

Debugging Tips and Tricks Part 2(Visual Studio Toolbox)

https://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Debugging-Tips-and-Tricks-Part-2?fbclid=IwAR0pfXFbExbKte7dpKmy7UwnqJmjCBU7hK_Yw6kZ3yAXSF7H57dGVN8-cFg

https://youtu.be/kQHbGPF7TZQ

Step int Specific(Visual Studio Text editor快顯功能表選項)

可以到指定的調用(呼叫)函式處

$ReturnValue (在Watch監看視窗裡,name欄位)

可以分開查看一個傳回值的各個部分



2:38:50

Debugging Tips and Tricks Part 1

DebuggerDisplay

〈Customize object displays in the Visual Studio debugger YOUR way〉

2:51:00 Text Visualizers 文字視覺化

2:55:00

New Little Features in Visual Studio 2019

快速建置新專案模板,大概只有在C# 才有像影片中那樣直接進入新專案也。



3:1:00 多重剪貼簿

Ctrl+Shift+v 選擇多重貼上——可以選擇剪貼簿中的多重選項以決定貼上哪一個



3:41:00 智能編碼(編程) intellicode

留言

熱門文章