6.S096 Lecture 5: C++ Introduction, Classes, and Templates
[Pages:16]Tuesday, January 22, 13
6.s096
Lecture 5
1
Today
?C++ (!)
? Compiling ? Memory management
? Classes ? Templates
2
Tuesday, January 22, 13
Tuesday, January 22, 13
C++
3
C++
? Bjarne Stroustrup ? 1983 ? Object-oriented (but later than Simula, Smalltalk) ? Like C, but introduces real objects and classes ? (plus loads of other features (kitchen sink?))
4
Tuesday, January 22, 13
g++ (C++ compiler)
? Very similar to gcc.
g++ --o test test.cpp ./test => hi from C++
#include
int main(){
printf("hi from C++\n");
}
5
Tuesday, January 22, 13
Wait... was that really C++?
? Yes. ? C++ is pretty close to being a superset of C. ? We know C, thus we'll build from that knowledge to learn C++.
6
Tuesday, January 22, 13
new memory management syntax
? The new operator allocates space on the heap. ? new and delete take the place of malloc and free.
int * numArray = new int[100];
delete numArray;
struct foo * bar = new struct foo; // delete later
7
Tuesday, January 22, 13
Tuesday, January 22, 13
Classes
8
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- introduction to psychology
- how to create instructor and course introduction videos
- subject introducing david m
- introduction class a
- introduction to object oriented programming
- 6 s096 lecture 5 c introduction classes and templates
- preparing an introduction and summary for your report
- giving an introduction speech
- sample letter of introduction to an instructor in a
- lesson plan introducing yourself british council