Microsoft PowerPoint - cpptutorial.ppt

Microsoft PowerPoint - cpptutorial.pptShort Description
C++ Tutorial. by Rob Jagnow. for MIT’s 6.837 Introduction. to Comptuer Graphics. Overview. . Pointers. . Arrays and strings. . Parameter passing …

Website: www.cs.rpi.edu | Filesize: 84kb

Content
C++ Tutorial
by Rob Jagnow
for MIT’s 6.837 Introduction
to Comptuer Graphics
Overview
?Pointers
?Arrays and strings
?Parameter passing
?Class basics
?Constructors & destructors
?Class Hierarchy
?Virtual Functions
?Coding tips
?Advanced topics
Pointers
int *intPtr;
intPtr = new int;
*intPtr = 6837;
delete intPtr;
int otherVal = 5;
intPtr = &otherVal;
Create a pointer
Allocate memory
Set value at given address
Change intPtr to point to
a new location
*intPtr 6837
intPtr 0×0050
*intPtr 5
intPtr 0×0054
otherVal
&otherVal
Deallocate memory
Arrays
int intArray[10];
intArray[0] = 6837;
int *intArray;
intArray = new int[10];
intArray[0] = 6837;

delete[] intArray;
Stack allocation
Heap allocation
Strings
char myString[20];
strcpy(myString, “Hello World”);
myString[0] = ‘H’;
myString[1] = ‘i’;
myString[2] = ‘’;
printf(”%s”, myString);
A string in C++ is an array of characters
Strings are terminated with the NULL or ‘’ character
output: Hi
Parameter Passing
int add(int a, int b) {
return a+b;
}
int a, b, sum;
sum = add(a, b);
pass by value
int add(int *…

Get the file Download here

AddThis Social Bookmark Button
Related Books:
  • Microsoft PowerPoint - Linux-3-Modules-26.ppt
  • Microsoft PowerPoint - Fayed-Tutorial-Arabic-Desktop-Suite-for-PDF.ppt
  • Microsoft PowerPoint - 09-DotNet
  • Microsoft PowerPoint - css training 101.ppt
  • Microsoft PowerPoint - Excel Tutorial #2- Calculating Mean and …
  • Microsoft PowerPoint - The Early History of Bentley.ppt
  • Microsoft PowerPoint - acer laptop
  • Microsoft PowerPoint - IPv6 Forum–IPv6 and P2P tutorial

  • Related Searches: , , , ,



    Comments

    Leave a Reply