Escolar Documentos
Profissional Documentos
Cultura Documentos
"
# %
int *intPtr;
int intArray[10];
intPtr = new int; intArray[0] = 6837;
*intPtr = 6837; #
*intPtr 6837
intPtr 0x0050
int *intArray;
delete intPtr; $ intArray = new int[10];
intArray[0] = 6837;
int otherVal = 5; intPtr
intPtr = &otherVal; ...
#
&& '
int add(int a, int b) { ) % 'a b
char myString[20]; return a+b;
strcpy(myString, "Hello World"); }
int a, b, sum;
# NULL '\0' sum = add(a, b);
myString[0] = 'H';
'
myString[1] = 'i';
myString[2] = '\0'; int add(int *a, int *b) { '
return *a + *b; a b* a
printf("%s", myString); (Hi } b '
add
int a, b, sum;
sum = add(&a, &b);
-
' , #ifndef _IMAGE_H_
'
#define _IMAGE_H_
int add(int &a, int &b) {
return a+b; #include <assert.h> . '
} #include "vectors.h“
. '
int a, b, sum; class Image {
sum = add(a, b);
public: ! '
...
'
private:
... ! '
'
};
#endif
/ #
# % image.h ' ( ' '
Image myImage; void SetAllPixels(const Vec3f &color);
myImage.SetAllPixels(ClearColor);
$
class Image { %
public:
Image(void) { Image(int w, int h) {
width = height = 0; width = w;
data = NULL; height = h;
} data = new Vec3f[w*h];
}
~Image(void) {
if (data != NULL)
0 % (
delete[] data;
}
Image myImage = Image(10, 10); %
int width;
int height; Image *imagePtr;
Vec3f *data; imagePtr = new Image(10, 10);
};
+
Image(Image *img) { .' ' 2
width = img->width;
% *
height = img->height;
data = new Vec3f[width*height];
bool IsImageGreen(Image img);
for (int i=0; i<width*height; i++)
data[i] = new data[i];
} 3
' 2
( .4 ' ' (
'
5 1$ Sphere::Sphere() : Object3D() {
class Object3D { radius = 1.0;
Vec3f color; }
};
class Object3D {
argv[0]
virtual void intersect(Vec3f *ray, Vec3f *hit);
}; argv[1] argv[argc-1] 7
#
1
9# ' ; <:
0 #define '
(
#define PI 3.14159265
#define sinf sin
int intArray[10]; '
intArray[10] = 6837;
0 printf cout ' '
printf("value: %d, %f\n", myInt, myFloat);
cout << "value:" << myInt << ", " << myFloat << endl; Image *img;
img->SetAllPixels(ClearColor); 60==
0 assert ' 9 :
assert(denominator != 0);
quotient = numerator/denominator;
' ''
2 *
friend protected
'
const static '
'
virtual void Intersect(Ray &r, Hit &h) = 0;