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





Qt /

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

List /

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

String /

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

Vector /

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

Set Multiset /

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

Deque /

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

Bitset /

bitset transform 1bitset 1

Map Multimap /

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

Valarray /

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

Queue Stack /

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

STL Basics /

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

STL Algorithms Binary search /

binary_search 3equal_range 5lower_bound 1upper_bound 2

STL Algorithms Min Max /

max 3max_element 3min 4min_element 3

STL Algorithms Heap /

make_heap 3pop_heap 1push_heap 2sort heap 2

STL Algorithms Iterator /

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

STL Algorithms Sorting /

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

STL Algorithms Merge /

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

STL Algorithms Helper /

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

STL Algorithms Modifying sequence operations /

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

STL Algorithms Non modifying sequence operations /

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

Class /

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

Overload /

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

Generic /

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

Console /

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

Language /

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

Development /

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

Data Type /

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

Data Structure /

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

File /

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

Function /

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

Pointer /

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