Anyway, I decided to share mine with everyone here! Feel free to use it as a reference, or even as study help for your own class!
Download Link 1
Calling by reference:
int x=0;
int *ptr;
ptr=&x; //ptr now points to x
void function(int *y)
{
*y++; //y points to x
}
int arr[5];
arr[3]; //same as *(arr+3)
pointer to function:
double (*fp)(double,double);
fp=pow; //fp now acts like pow
Useful String Functions:
int atoi( const char *nPtr )
char *gets( char *s );
char *strcpy( char *s1, const char *s2 )
char *strcat( char *s1, const char *s2 )
char *strstr( const char *s1, const char *s2 );
Structs:
typedef struct dummyname
{
int x;
//elements
}StructName;
StructName identifier;
indentifier.element=value;
Dynamic Memory:
ptr = (int*)malloc(5*sizeof(int));
Linked Lists:
typedef struct node
{
char data;
struct node *next;
}Node;
Node *p;
p=(Node*)malloc(sizeof(Node));
p->data=’a’;
p->next=head;
head=p;
Enum:
typedef enum dummyname
{
sun,mon,tues...
}Weekday;
(sun=0,mon=1,....)
force values:
enum{sun=5,mon=8,...};
Union:
As large as its largest element.
Holds one at a time.
Declare like a struct.
Preprocessor:
#define SQUARE(x) ((x)*(x))
#undef
#if, #ifdef, #else, #endif
#define TOKCAT(x,y) x ## y
Variable Length Args:
int funct(int n,...)
{
va_list args;
va_start(args,n);//n is first param
loop() variable=va_arg(args,type);
va_end(args);
}
Command Line Args:
int main(int argc,char *argv[])
iostream:
using namespace std;
cout<<”stuff”;
cin>>variables;
Default Args:
int func(int x=1);
Templates:
template <class T>
T square(T value)
{
return value*value;
}
int x=square(5);
float y=square(5);
Classes:
Class ClassName
{
public:
void func();
const int x;
private:
void inlineFunct(){return 0;};
//private ones
};
void ClassName::funct()
{}
//constuctor
ClassName::ClassName()
{/*default values*/}
//destructor
ClassName::~ClassName(){}
Data Initializer:
ClassName::ClassName()
:x(0)
{/*default values*/}
Composition:
Class1::Class1(Class2 &identifier)
{}
Friend Functions:
class ClassName
{
friend void func();
public:
private:
}
void func(ClassName name)
{
//access private stuff
}
new and delete:
int ptr = new int(3.141592654);
int arr = new int[10];
delete []arr;
Static Class Members:
ClassName::var
InstanceName.var
ClassName::ClassName()
{
var++;
}
Operator Overloading:
class ClassName
{
friend ostream& operator<<( ostream&, const ClassName&);
ClassName& ClassName::operator=(const ClassName x)
{
var1=x.var1;
return *this;
}
ostream& operator<<(ostream &o, const ClassName x)
{
o<<x.var1<<etc;
return o;
}
That's really cool of her to let you do that.
ReplyDeleteGood luck on the exam!
Man, I gotta teach myself how to make basic apps in Access within the next week and a half. I better get to it.
ReplyDelete~H. Coct
this actually helped me with exam :X so nice thank you
ReplyDeletelooks okay to me, good luck on the exam.
ReplyDeleteGood luck!
ReplyDeleteGood luck with your test,im sure you'll do well.
ReplyDeleteI remember we got this for my programming course, must be a universal thing :D
ReplyDeleteI hope the test went well!
ReplyDeleteGood luck!
ReplyDeletethanks for refreshing knowledge :) good luck
ReplyDeleteMy Digital Design teacher did the same, it made the test a bit too easy :p
ReplyDelete