C++ examples (example source code) Organized by topic






Qt /

Color Dialog 1Drag Drop 7
Draw Shape 8Font Dialog 1
foreach 1Layout 8
Open File Dialog 2QAbstractItemModel 1
QAbstractItemView 1QAbstractListModel 3
QAbstractTableModel 3QAction 4
QApplication 2QAssistantClient 1
qBinaryFind 1QBrush 5
QBuffer 7QByteArray 1
QCalendarWidget 1QCheckBox 1
QComboBox 1QContextMenuEvent 1
qCopyBackward 1QDataStream 4
QDate 2QDBusMessage 1
qDebug 2QDesignerCustomWidgetInterface 2
QDialog 9QDir 5
QDirModel 1QDockWidget 2
QDomDocument 3QDomElement 5
QDomNode 1QDoubleValidator 1
QDrive 1QEvent 2
QFile 11QFileDialog 2
QFileInfo 1QFocusEvent 1
QFont 3QFontDatabase 1
QFrame 1QFtp 2
QGraphicsItem 2QGraphicsPolygonItem 1
QGraphicsRectItem 1QGraphicsView 1
QGridLayout 2QGroupBox 2
QHash 3QHBoxLayout 1
QImage 6QImageWriter 1
QInputDialog 5QKeyEvent 1
QLabel 7QLayout 2
QLCDNumber 1QLinearGradient 1
QLineEdit 5QList 10
QListIterator 1QListView 4
QListWidget 5QListWidgetItem 2
qLowerBound 1QMap 3
QMenu 3QMessageBox 7
qMin 1QMouseEvent 5
QMovie 1QMultiHash 1
QMultiMap 2QMutableIterators 1
QMutableListIterator 1QMutexLocker 1
QNetworkAccessManager 3QObject 2
QPainter 20QPalette 1
QPen 2QPixmap 3
QPlainTextEdit 1QPointer 1
QPrintDialog 1QPrinter 5
QProcess 4QProgressBar 1
QPushButton 6QQueue 1
QRadialGradient 4QRadioButton 1
QReadWriteLock 1QRegExp 1
QRegExpValidator 1QScriptEngine 3
QSemaphore 3QSet 2
QSignalMapper 1QSlider 5
qSort 1QSortFilterProxyModel 2
QSpinBox 5QSplashScreen 1
QSplitter 3QSqlDatabase 5
QSqlRelationalTableModel 2QSqlTableModel 1
QStack 5QStackedLayout 1
QStackedWidget 2QStandardItem 1
QStandardItemModel 3QStatusBar 1
QString 6QStringList 9
QStringListModel 2QStyle 4
QSvgWidget 1QSystemTrayIcon 1
QTabletEvent 1QTableView 5
QTableWidget 4QTabWidget 1
QTcpServer 4QTcpSocket 1
QTest 1QTextBlockFormat 2
QTextBrowser 1QTextCharFormat 1
QTextCursor 2QTextDocument 4
QTextEdit 3QTextFrame 2
QTextImageFormat 2QTextList 2
QTextStream 5QTextTableFormat 1
QThread 5QTime 1
QTimeLine 1QTimer 1
QToolBar 1QTranslator 1
QTreeView 7QTreeWidget 1
QTreeWidgetItem 1QUdpSocket 2
QUiLoader 2QVBoxLayout 2
QVector 4QWhatsThis 1
QWidget 12QWindowsStyle 1
QWizard 3QX11EmbedContainer 1
QX11EmbedWidget 1QXmlDefaultHandler 2
QXmlStreamWriter 2Signal 10
Sqlite 1ToolTip 3
Window 7

List /

list assign 2list begin end 1
list compare 1list const_iterator 2
list display 4list erase 2
list find 2list insert 6
list iterator 6list merge 2
list push pop 5list remove 2
list reverse 1list sort 2
list splice 4list swap 1
list unique 3list 14
your list 1

String /

char array string 13string append 2
string array 1string assign 1
string at 4string char array 1
string compare 12string concatenation 4
string copy 4string data 2
string empty 1string erase 3
string find 16string insert 5
string iterator 6string length 1
string output 3string read 4
string replace 4string resize 1
string reverse 6string search 1
string size 4string sort 1
string subscript indexer 4string substr 5
string swap 1string 8
your string 1

Vector /

object vector 4vector at 1
vector back 2vector begin end 2
vector bound 2vector capacity 2
vector clear 1vector compare 4
vector count 1vector definition 3
vector display 2vector erase 5
vector find 13vector front 2
vector indexer 4vector insert 10
vector iterator 7vector merge 2
vector push pop heap 4vector reserve 1
vector reverse 2vector reverse_iterator 1
vector size 4vector sort 5
vector subscript indexer 7vector 18

Set Multiset /

difference 6intersect 3
multiset bound 2multiset count 2
multiset equal_range 1multiset erase 6
multiset find 1multiset insert 3
multiset iterator 2multiset 4
set begin end 1set bound range 1
set compare 2set insert 1
set 7union 4

Deque /

deque display 1deque erase 1
deque find 3deque indexer 1
deque insert 2deque iterator 2
deque pop 2deque push 2
deque resize 1deque reverse 1
deque size 1deque subscript indexer 3
deque 11

Bitset /

bitset transform 1bitset 1

Map Multimap /

map compare 2map display 1
map empty 1map erase 3
map find 8map indexer 2
map insert 2map iterator 8
map search 4map subscript indexer 1
map update 2map 12
multimap count 1multimap insert 2
multimap interator 1multimap 1
pair 10transform 3

Valarray /

valarray cshift 1valarray indexer 1
valarray min max sum 1valarray resize 1
valarray slice 1valarray subscript indexer 1
valarray 7

Queue Stack /

priority_queue 9queue 6
stack 9your queue 1
your stack 3

STL Basics /

array algorithms 8array sort 2
back_inserter 2binary_function 1
container as parameter 4Function object 1
Memory 1out_of_range exception 3
parameter constraint 1predicate 8
template Array 2

STL Algorithms Binary search /

binary_search 3equal_range 5
lower_bound 1upper_bound 2

STL Algorithms Min Max /

max 3max_element 3
min 4min_element 3

STL Algorithms Heap /

make_heap 3pop_heap 1
push_heap 2sort heap 2

STL Algorithms Iterator /

const_interator 3const_reverse_iterator 1
custom iterater 4insert_iterator 1
istream iterator 6iterator 3
reverse_iterator 1template iterators 2

STL Algorithms Sorting /

custom comparer 2lexicographical_compare 2
nth_element 5partial_sort 4
partial_sort_copy 2qsort 1
sort 15stable_sort 1

STL Algorithms Merge /

includes 5inplace_merge 3
merge 9set_difference 2
set_intersection 3set_symmetric_difference 3
set_union 3

STL Algorithms Helper /

accumulate 10adjacent_difference 5
bind1st 1bind2nd 6
distance 2divides 4
gslice 1inner_product 5
make_pair 1mem_fun_ref 2
multiply 2negate 3
next_permutation 2not1 1
numeric_limits 5partial_sum 6
prev_permutation 3slice 1

STL Algorithms Modifying sequence operations /

copy 16copy_backward 2
copy_if 1fill 4
fill_n 4generate 6
generate_n 4iter_swap 2
partition 2random_shuffle 5
remove 7remove_copy 2
remove_copy_if 3remove_if 3
replace if 3replace 4
replace_copy 2replace_copy_if 3
reverse 6reverse_copy 3
rotate 4rotate_copy 3
stable_partition 2swap 4
swap_ranges 4transform 17
unique copy 7unique 3

STL Algorithms Non modifying sequence operations /

adjacent_find 4count 7
count_if 1equal 3
find if 5find 15
find_end 2find_first_of 2
for_each 9mismatch 4
search 2search_n 2

Class /

Abstract Class 4Base Class 6
cast 8Class Access 2
Class Basics 9Class Member 5
combination 1Constructor 12
conversion Function 2Copy Constructor 3
Derived 6Destructor 8
dynamic_cast 1Friend 6
Inheritance Multiple 5Inheritance 12
inline 6Instance 4
Interface 4object pointer 12
Polymorphism 5Private 7
Protected 4Public 8
static 13Struct Class 7
template class 18this 3
Union Class 4virtual function 21

Overload /

And 1Assign 5
Boolean Operator 2Cast 2
Comma 1Compare 6
Divide 2Extractor 3
Friend Plus 1Index 6
Inserter Extractor 6Inserter 7
Minus Minus 2Minus 4
New Delete 3Parenthesis 4
Plus Plus 4Plus 12
Pointer Operator 1Product 1
Return Operator 1Stream Operator 1
Unary Operator 2Underflow 1

Generic /

Generic Algorithm 2Generic Class 3
Generic List 1Generic Queue 1
Generic Stack 2Template Class 1
Template Overload 3

Console /

cin get 6cin getline 2
cin ignore 2cin manipulator 2
cin 9cout boolalpha 2
cout custom 6cout fill 6
cout flag status 4cout flag 1
cout hex 2cout manipulator 13
cout pcount 1cout scientific 4
cout setf 8cout setiosflags 3
cout setw setprecision 4cout sync clear 2
cout terminator 1cout uppercase 1
cout width 4cout 4
ostream iterator 2

Language /

Break 2Comments 1
Const 1Do While 3
For 4If 8
Malloc 1Mod 1
NameSpace 11New 8
Operator 19Prefix postfix 2
Register 1Static 9
Switch 3this 2
Throw 15try catch 14
Using 1While 8

Development /

Argv Argc 1command line 2
const cast 4Dynamic Cast 2
Escape Sequences 3Exception 12
macro 2Mutable 1
new delete 4Random 3
Reinterpret cast 1static cast 2
Time 4typeid 10

Data Type /

bit 1bool output 4
Bool 2Char Array Function 20
Char Array 5Char 12
Complex 3constant 2
Date 1Decimal 1
double output 8Double 13
enum 5float output 7
Float 8Hexadecimal 11
int output 14Int 11
Long 4Octal 1
pointer 4reference 13
sizeof 2String 21
Struct 8Union 3
unsigned 2

Data Structure /

Array Object 9Array Pointer 1
Array Two Dimension 4Array 8
Bitset 1Deque 10
List 34Map 15
Priority Queue 4Queue 6
Set 3Sort 1
Stack 2Valarray 3
Vector Utility 34Vector 34

File /

Append 2Array Based IO 3
Binary File 5Exception Error 1
File Convert 1File End EOF 3
File Read Write 5File Read 8
File Size 1File Status 4
File Utility 15File Write 3
fstream 6ifstream 13
istrstream 1Object Serialization 3
Object Serialize 2ofstream 14
ostrstream 4rename 1
Stream iterator 2String Based IO 1
String stream 3Text File 10

Function /

Basics 5Function Adaptor 3
Function Arguments 4Function Define 1
Function main 1Function Overloaded 9
Function Parameters 10Function Pointer 3
Function Prototype 3Function Recursion 1
Function Return 3Function Template 16
Function Variables 3generic parameters 6
Optional Arguments 2Variable Scope 6
Virtual 9

Pointer /

Auto Pointer 2Pointer Array 7
Pointer Object 4Pointer Primitive 12