The program i created was rewritten extremely compressed and ugly to save space for future material i decide to put on it. At the moment though here is my cheat sheet.
Source Code
----------------------------------------------------------------------------------------------------------
#include <iostream>--------------------------------------------------------------------------------------------------------------
using namespace std;
class study
{
public:
study(){x = 0,y = 0; n++;}
study(int a, int b);
void print(void);
void displayN(void)const;
friend study change(study obj){ cin>>obj.x; cin>>obj.y; return obj;}
friend int area(study);
study& operator+(study);
study& setX5(void){this->x = 5; return *this;}
study& sety10(void){this->y = 10; return *this;}
friend ostream& operator<<(ostream &output, study &obj){output<<"("<<obj.x<<","<<obj.y<<")"<<endl; return output;}//stream overloading friend
~study(){x = 0; y=0; if(n!=0){cout<<"Object deconstruction"<<" Objects remaining = "<<n--<<endl;}}
private://methods in here called utility function
static int n;
int x;
int y;
};
int study::n = 0;
void study::print(void){cout<<x<<endl; cout<<y<<endl;}
void study::displayN(void)const{cout<<"The number of objects created is: "<<n<<endl;}
study::study(int a, int b){ n++; x = a; y = b;}
int area(study obj){ return obj.x*obj.y;}
study& study::operator+(study obj2){this->x = this->x + obj2.x; this->y = this->y + obj2.y; return *this;}
int main()
{
study obj1;//x = 0 , y = 0
study obj2(2,4);//x = 2 , y = 4
const study obj3(5,4);
study *obj4 = new study(5,5);
obj1.print();//output: 0 endl 0
obj2.print();//output: 2 endl 4
cout<<"The area of obj2: "<<area(obj2)<<endl;//object from area function gets deconstructed
obj1 = change(obj1);//x = 6 , y = 5
obj1 = obj1.operator+(obj2);
obj1.print();// 8, 9
obj1 = obj1 + obj2;
obj1.print();//10,13
obj1.displayN();//3
//obj3.print(); won't work because const objs can only use const methods
obj1.setX5().sety10();//cascading member list
obj1.print();
cout<<obj1<<endl;//use of operator overloading of <<. Method has to be a friend. ostream for output. istream for input.
delete obj4;
return 0;
}
As you can see it is pretty ugly, but should really benefit me in terms of knowing the syntax of certain programing styles/commands.
good luck on the test! :D
ReplyDeleteGood luck. Cheat sheet!
ReplyDeleteUm, what? I'm trying to teach myself the basics of C++ and I still have no clue what your programs say. Let me get this straight, you made a program to make a cheat sheet for a programming test?
ReplyDeletelook good to me, it's so helpful when you're allowed a formula sheet.
ReplyDeletei only have a basics of C++, but doesnt it acually describe studying? :)
ReplyDeletewow good luck bro
ReplyDeleteHow to Hack Life.
hm nothing special there :3
ReplyDeleteGood luck in the exam!!
ReplyDeletei would gladly give you something useful here, but i dont understand anything in matters of IT. so i just wish you the best of luck for your exams
ReplyDelete:D nice! but why does he let u do this?
ReplyDeleteI can't understand much of that at all haha.
ReplyDeletecool post, bro!
ReplyDeleteProgramming is tough. I did Java for a while. It's a lot different than C++
ReplyDeleteBest of luck mate.
ReplyDeleteGood luck! :)
ReplyDeleteLooks fine. I only know the basics of C++ like stringstream and ifstream etc. Still wanna know how to work with classes..
ReplyDeleteGood luck! One of my teachers at the university also had the same system. At first exam one sided sheet and at second two sided.
ReplyDeleteLooks like a good cheat sheet. Goodluck on your test man! :) Followed
ReplyDeleteI might be "borrowing" that cheatsheet some time :P
ReplyDeleteI agree with most of your points, because this article gives the light in which we can observe the reality and I take positive information on this great blog. It is very effective data provide me as well as and new experience learn from it. We can use this cell phone detector and cell phone detection to stop this cheating over phone.
ReplyDelete