













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














intArray[10];
intArray[0]
int
*intArray;
intArray
new
int[10];
intArray[0]
... delete[]
intArray;
myString[20];
strcpy(myString,
"Hello
World");
myString[0]
myString[1]
'i';
myString[2]
printf("%s",
myString);
Hi
add(int
&a,
int
&b)
return
a+b;
} int
a,
b,
sum;
sum
add(a,
b);
#ifndef
#define
#include
<assert.h>
#include
"vectors.h“
class
Image
public:
private:
}; #endif
Note that “private:” is the default
image.h
void
SetAllPixels(const
Vec3f
&color);
image.C
void
Image::SetAllPixels(const
Vec3f
&color)
for
(int
i
i
width*height;
i++)
data[i]
color;
main.C
myImage.SetAllPixels(clearColor);
class
Image
public:
Image(void)
width
height
data
~Image(void)
if
(data
delete[]
data;
} int
width;
int
height;
Vec3f
*data;
Image(Image
*img)
width
img->width;
height
img->height;
data
new
Vec3f[width*height];
for
(int
i=0;
i<width*height;
i++)
data[i]
new
data[i];
} Image(Image
*img)
width
img->width;
height
img->height;
data
img->data;
bool
IsImageGreen(Image
img);
bool
IsImageGreen(Image
*img);
bool
IsImageGreen(Image
&img);
Sphere::Sphere()
Object3D()
radius
class
Object3D
virtual
void
setDefaults(void)
color
}; class
Sphere
public
Object3D
void
setDefaults(void)
color
radius
*mySphere
new
Sphere();
Object3D
*myObject
mySphere;
Object3D
virtual
void
intersect(Vec3f
*ray,
Vec3f
*hit);
}; class
Sphere
public
Object3D
virtual
void
intersect(Vec3f
*ray,
Vec3f
*hit);
}; myObject->intersect(ray,
hit);
Superclass Subclass
#define
#define
#define
sinf
sin
printf
cout
printf("value:
%d,
%f\n",
myInt,
myFloat);
cout
"value:"
myInt
myFloat
endl;
assert
assert(denominator
quotient
numerator/denominator;
“Segmentation fault (core dumped)”
int
intArray[10];
intArray[10]
Image
*img;
img->SetAllPixels(ClearColor);