Path: C++ : C++ programming :
Programming
How to author computer programs using the C++ programming language...
reference book: The C++ Programming Language 2nd edition by Bjarne Stroustrup
reference book: UNIX Network Programming: Stevens, W. Richard
reference book: Multithreaded Programming With Pthreads: Bil Lewis, Daniel J. Berg
reference site: Microsoft Win32/Win64 C API
Bajarne Stroustrup is the inventor of the C++ prgramming language.
This page lists the things you should know to program C++
on UNIX and Windows operating systems. If you wish to learn the C++ programming
language and alreay know how ot porgram read Bjarne Stroustrup's book
"The C++ Programming Language 2nd edition" and know all
the terms listed. You should go to a university to learn computer science using standardized C++.
Learn how to begin programming in C++ for developing
software for the modern world. This site shows how to program in
C++
for client / server and application development for windows and BSD/Linux.
You should know a shell scripting language, an interpreted programming langauge
and a pointer language. /bin/sh, perl and STL C++ are the three for me.
/bin/sh is a shell scripting language. Perl is a practicle extraction
and report language. C++ is hybrid function and object oriented
pointer language. Other langugaes exist and are used to be succinct
in programming make finding the solution quicker. Most of the languages
exist becuase of C/C++.
C++98, C++11 and C++15 are standardized programming language;
and it is not a designer programming laguage that changes over night.
Your C++ compiler choice is important:
C++ Filter
Borland C++ Builder
Microsoft Visual C++
MinGW C++
EGCS C++
CYGWIN C++
C++ APIs used to program:
IOStreams
APIs From Me
STL (STLport )
Berkely Sockets API
Oracle Berkely DB API
MySQL C API
POSIX Threads API
Win32/Win64 C API
Boost C++ API
OpenGL API
C++ -
Extended BNF grammar file for the C++ programming language
C++ in outline form:
Compiler Explained
Theory of Computation
Finite Automa
Computer Programma
Macro C Pre-Processor
C++ Compiler
Assembly Language
Object Code
The Linker
Shared Object File
Executable
Static Library
Compiler Choice
Operating System Choice
How to Begin a Simple Program
Main Entry Point
Functions
Statement
Expression Syntax
Variables
Local Variables
Global Variables
Stack Variables
Dynamic Variables
Class Variables
Primative Data Types
Integer
Floating Point
Character
Strings
Array
Pointers
Class Variable
new and delete
auto_ptr
casting or type conversion
Pointer Functions
References
Enumerated Types
Sequence
Statement
Compund Statement
Selection
if statement
switch statement
?: operator
Repitition
while loop
do while loop
for loop
Math
Input and Output
IOStreams Class Library
Text File I/O
Binary File I/O
Terminal Output
Keyboard Input
Functions
Operators
Keywords
Identifiers
Struct
Union
Typedef
Namespaces
Classes
inharatence
encapsulation
information hiding
constructor
deconstructor
member operator
member function
data member
templates class
templates member function
templates function
default templates parameters
virtual member function
pure virtual member function
run time type information
exception handling
strong data type
abstract base class
friend statement
inline wrapper class
coupling
cohesion
base classes
derived classes
extern
static
volatile
explicit
mutable
register
inline
extern "C"
default function parameter values
overloaded functions
overloaded operators
template functions
template operators
STL
IOStreams
iostream
fstream
iomanip
sstream
list
vector
map
mmap
hashmap
string
stack
valarray
algorithm
auto_ptr
typeinfo
Standard C APIs
cstdlib
cstdio
cstring
cctype
cmath
ctime
climits
Windows C APIs
windows.h
winsock2.h
UNIX C APIs
unistd.h
signal.h
sys/wait.h
sys/types.h
System V Inter-Process Communcation
Daemon Processes
POSIX Threads
Berkely Sockets
tcp_stream.h
tcp_server.h
Building Programs
Testing Programs
Optimizing Programs
Bad Programming to Avoid
return from the middle of a function
goto
one letter variable names
repeating code should be an abstraction
don't put all the code in one file
don't make a function monalitic
procedures should be named a verbs
functions should be named a nouns
Abstractions
Polymorphism
Recurshion
Recipies
Metaphors
Functionoid
Command Line User Interface
Menu User Interface
Command Shell User Interface
ommon Gateway Interface (CGI) Programming
Sockets Programming
Mult-Threaded Programming
IOStreams
cout
cin
cerr
fstream
ios::in
ios::out
ios::ate
ios::trunc
ios::app
ios::binary
fstream::opean()
fstream::seekg()
fstream::tellg()
fstream::get()
fstream::getline()
fstream::write()
fstream::read()
fstream::flush()
fstream::clearerr()
fstream::operator void*()
fstream::operator <<()
fstream::operator >>())
endl
flush
fstream::open()
fstream::close()
STL - standard template library
list< T > - linked list STL data structure template
vector< T > - array STL data structure template
stack< T > - stack STL data structure template
map< Key , Data > - assiciative array STL data structure
string - string STL data structure template
stringstream - string stream STL data structure template
sort() - quick sort STL function template
binary_search() - binary search STL function template
find() - linear search given a value STL function template
find_if() - linear search given a function STL function template
win32/win64 C API programming (understanding windows applications)
WinMain()
Create Window(s)
Call Back Function (WinProc and DefWindowProc)
Event Driven System
The Message Loop
MessageBox()
Windows Events in C API
WM_CHAR
WM_SIZE
WM_CREATE
WM_DESTORY
WM_PAINT
WM_COMMAND
WM_KEYDOWN
WM_KEYUP
DefWindowProc()
How to make the File Menu
How to compile a C++ program:
#include <iostream>
using namespace std;
int
main(int argc, char** argv)
{
cout << "Hello, world!" << endl;
return 0;
}
On windows:
c:\myproject> cl /O2 /EHsc /Femy_program.exe my_program.cpp mylib.cpp ws2_32.lib
c:\myproject> my_program.exe
On BSD and Linux (Application):
$ c++ -static -O2 my_program.cpp mylib.cpp -o my_program
$ strip ./my_program
$ ./my_program
On BSD and Linux (shared object file):
$ c++ -shared -O2 mydll.cpp -o libmydll.so
$ export "LD_LIBRARY_PATH=${LD_LIBRARY_PATH};."
$ strip ./libmydll.so
$ c++ -O2 mydll_use.cpp -o mydll_use -l mydll -L .
$ strip ./mydll_use
$ ./mydll_use
How to build a windows application
c:\myproject> cl /O2 /EHsc /Femyprogram.exe my_winprogram.cpp mylib.cpp use32.lib kernel32.lib gdi32.lib ws2_32.lib /link /SUBSYSTEM:WINDOWS
c:\myproject> mywinprogram.exe
Winsock2 Sockets API
A listing of the win32/win64 C API functions
CreateThread()
CreateMutex()
MutexLock()
MutexUnlock()
CreateProcess()
CreatePipe()
GetModuleFileName()
LoadLibray()
GetProcAddress()
FreeLibrary()
CloseHandle()
WaitForSingleObject()
ReadFile()
WriteFile()
ReadConsole()
WriteConsole()
AttachConsole()
OpenFile()
CreateWindow()
DestroyWindow()
ResizeWindow()
SendMessage()
MoveWindow()
ShowWindow()
SetFocus()
MoveTo()
LineTo()
FillRect()
BitBlit()
matt_win.h - C++ inline wrapper classes for the win32/win64 C API
Application
Window
Fram
Panel
Layout
FlowLayout
GridLayout
CustomLayout
ImageButton
Button
Image
Label
Canvas
TabCtrl
ScrollBar
Slider
Text
ComboBox
ListBox
TreeCtrl
ProgressBar
StatusBar
ButtonBar
MenuBar
Menu
MenuItem
IPAddress
BSD/Linux/Windows C API Calls (syscalls and libc calls)
fork() - UNIX
alarm() - UNIX
waitpid() - UNIX
signal() - UNIX
kill() - UNIX
open()
stat()
read()
write()
close()
flock()
printf()
puts()
fopen()
fclose()
feof()
srand()
rand()
dlopen()
dlsym()
dlclose()
tempnam()
fprintf()
sprintf()
sscanf()
scanf()
fscanf()
getchar()
fgetc()
fputc()
puts()
fgets()
getch()
strlen()
strcpy()
strncpy()
strcmp()
strtok()
strchr()
strrchr()
strstr()
strrstr()
strcasecmp() -- unix
_stricmp() -- windows msvcrt.dll
strncmp()
strdup()
memset()
atoi()
atof()
atol()
atod()
socket() - Berkeley Sockets API
listen()
bind()
accept()
connect()
recv()
send()
recvfrom()
sendto()
select()
gethostbyname()
gethostbyaddr()
poll()
setsocketopt()
pipe()
dup2()
exec()
getpid()
getcwd()
mkdir()
rmdir()
unlink()
ftruncate()
chdir()
exit()
mmap()
system()
popen()
pclose()
wait()
malloc()
free()
time()
strftime()
daemon()
pthread_create() - POSIX threads library
pthread_destroy()
pthread_yield()
pthread_self()
pthread_mutex_init()
pthread_mutex_lock()
pthread_mutex_unlock()
pthread_mutex_destory()
pthread_cond_init()
pthread_cond_destroy()
pthread_cond_wait()
pthread_cond_signal()
pthread_cond_broadcast()
Object Oriented Database (BSD/Linux/Windows)
sql_tools
db_tools
disk_tools
Debugging Programs
Compiling with Debugging Symbol
Using the Debugger
Print Statements
Abort Function
SIGKILL
The "core" Dump File
How to use gdb GNU debugger
$ c++ -g myprogram.cpp -o myprogram
$ gdb ./myprogram
(gdb) run
... crash ...
(gdb) where
line 35 at strcpy()
(gdb) quit
$ vi +35 myprogram.cpp
Levels of Abstraction
Abstraction without Expens
Cohesio
Coupling
Web Server Extention
NT Service
CGId
CGI programming
programming recipies in outline form:
counter
accumulator
sort
quick sort algorithm
bubble sort
insertion sort
linked list
stack
queue (priority queue)
hash table (big O of 1)
balanced search tree
AVL
red black
splay tree
general tree
btree
disk hashtable
hash function
mod
the four counting problems
order matters and replacement does not (multiply each choice)
order matters with replacement (like factorially each chocce)
order does not matter with without replacement (nCr )
order does not matter with replacement (stars and bars )
factorial
prime numbers
big O (number of comparisons used in an algorithm)
disk list
inline wrapper class
reuse
address of operator
pointer
while
for
do while
if, else if, else
switch statement
array (multi-dimentional array)
index variable
linear search
binary search
linear algebra (matrix)
3d computer graphics
calculous
algebra
probability and statistics
boolean algebra
descret math
set math and logic
trigonometry
vectors
vector sapce
vector set
rank
parser (recrsive decent and parse matrix)
interpreter
compiler
dynamic compiler (java hot spot)
finite automa (program in structured programming language statements)
computer programma (assembly language or interpreter codes)
thery of computation (compiler)
intermediate code
peephole optimizer
assembly language
goto logic (goto hell)
integer math
floating point math
bitwize operations
left bit shift one is divide by two (quick)
line bresenham
line DDA (data drawing algorithm)
buffer math (buffer overflow)
string class
sequence, selection, repetition
operating systems
single task (preemptive)
mutli-task (preemptive)
mercator map algorithm
dakart sortest path algorithm
dakart minimum spaning tree
apha-beta pruning
the eval() function
the machineeval() function (dynamic machine code eval() function)
scalar variable (number and string at once)
strong data type (every operator overloaded for a class)
parametrized data type (C++ template)
operator overloading
object oriented programming
the class statement (first in simula 60)
the method
design by contract
is-a, has-a, uses-a
function oriented programming
procedure
function
record
dealership locator math (zip codes)
POSIX threads API
Berkeley sockets API
Win32 C API
linear programming (make all expressions add and multiply)
a solve() function (linked lists)
reverse the operators for N-th term
imaginary numbers
least squares for error reduction
sinusoidal waves for sound
fast furious transfer
circumvent system to find answer
use the compiler to answer a question
flat file (CSV comma seperated values)
binary file raw memory in a file
object input output
martial an object
input output
report to the screen
regular expressions
perl (practical extraction and report language)
polymorpihic (qsort() a pointer function passed in)
reference
pass by value
struct return
struct
aggregate data type
stack memory
dynamic memory
virtual memory
memory mapped files
indirect goto (jmp edx, ret)
c call interface
recursion (repeat through function calling)
local stack pointer
buffer overrun
cheat at writing a lot of code with advanced language features
macro (expand)
phreaking (DTMF, 2600 Hz)
stack calculator
relational database
no real addresses (go throuh a data structure to get addresses)
compactify and shrink file
programmatic database (Berkeley DB)
SQL database (oracle)
worms (CodeRed)
viruses (iloveyou)
natural language parser
natural language query
artificial intelligence
srai (stimulus response aritficial intelligence (ALICE BOT))
question answer A.I. print(eval(rephrease(english_parse(read_question()))))
neural net
strict type checking
lint C program checker
array of int for indexes into another array
sort() an array a different way without changing the array
metaphor
fuzzy logic (a maybe comparison in a program)
spell check the soundex() function
local reference to avoid repeated expressions
do not divide by zero
do not mod by zero
do not have a return from the center of a block
do not have repeated expressions
do not have a single letter variable
do not have junk pointer
do not use a null pointer
sort the finite automata
peep hole optimizer (if "RTRIM" == opcode
and next == "ASSIGN" then add_code "CHOMP" end)