Skip to content

add 42 to 73 for c++ #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions C++/44_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//This is Sally.h file
#ifndef SALLY_H
#define SALLY_H

class Sally
{
public:
Sally();
void printShiz();
void printShiz2() const;
protected;
private;
};

#endif //SALLY_H

//This is Sally.cpp file
#include "Sally.h"
#include <iostream>
using namespace std;

Sally::Sally()
{
}

void Sally::printShiz()
{
cout << "i am a regular function"<<endl;
}

void Sally::printShiz2() const{
cout<< "i am the constant function"<<endl;
}

//This is main.cpp file
#include <iostream>
#include "Sally.h"
using namespace std;

int main(){
Sally salObj;
salObj.printShiz();

const Sally constObj;
constObj.printShiz2();
}
40 changes: 40 additions & 0 deletions C++/45_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//This is Sally.h file
#ifndef SALLY_H
#define SALLY_H

class Sally
{
public:
Sally(int a,int b);
void print();
private:
int regVar;
const int constVar;
};

#endif //SALLY_H

//This is Sally.cpp file
#include "Sally.h"
#include <iostream>
using namespace std;

Sally::Sally(int a,int b)
:regVar(a),
constVar(b)
{
}

void Sally::print(){
cout << "regular var is: " << regVar << "const varible is :" << constVar <<endl;
}
//This is main.cpp file
#include <iostream>
#include "Sally.h"
using namespace std;

int main()
{
Sally so(3,87);
so.print();
}
82 changes: 82 additions & 0 deletions C++/46_&47_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//This is Birthday.h file
#ifndef BIRTHDAY_H
#define BIRTHDAY_H

class Birthday
{
public:
Birthday(int m, int d,int y);
void printDate();
private:
int month;
int day;
int year;
};

#endif // BIRTHDAY_H

//This is Birthday.cpp file
#include "Birthday.h"
#include <iostream>
using namespace std;

Birthday::Birthday(int m, int d, int y)
{
month = m;
day = d;
year = y;
}

void Birthday::printDate(){
cout << month << "/" << day << "/" << year <<endl;
}

//This is People.h file
#ifndef PEOPLE_H
#define PEOPLE_H

#include <string>
#include "Birthday.h"
using namespace std;

class People
{
public:
People(string x,Birthday bo);
void printInfo();
private:
string name;
Birthday dataOfBirth;
};

#endif // PEOPLE_H

//This is People.cpp file
#include "People.h"
#include "Birthday.h"
#include <iostream>
using namespace std;

People::People(String x,Birthday bo)
: name(x), dataOfBirth(bo)
{
}

void People::printInfo(){
cout << name << "was born on";
dataOfBirth.printDate();
}
//This is main.cpp file
#include <iostream>
#include "Birthday.h"
#include "People.h"
using namespace std;

int main()
{
Birthday birthObj(12,28,1986);

People buckyRoberts("Bucky the King",birthObj);
buckyRoberts.printInfo();

}
25 changes: 25 additions & 0 deletions C++/48_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//This is main.cpp file
#include <iostream>
using namespace std;

class StankFist{
public:
StankFist()(stinkyVar=0;)
private:
int stinkyVar;

friend void stinkysFriend(StankFist &sfo);
};

void stinkysFriend(StankFist &sfo)
{
sfo.stinkyVar=99;
cout << sfo.stinkyVar <<endl;
}

int main()
{
StankFist bob;
stinkysFriend(bob);

}
36 changes: 36 additions & 0 deletions C++/49_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//This is Hannah.h file
#ifndef HANNAH_H
#define HANNAH_H

class Hannah{

public:
Hannah(int);
void printCrap();
private:
int h;
};
//This is Hannah.cpp file
#include <iostream.h>
#include "Hannah.h"
using namespace std;

Hannah::Hannah(int num)
:h(num)
{
}

void Hannah::printCrap(){
cout << "h=" << h <<endl;
cout << "this->h=" << this->h <<endl;
cout << "(*this).h=" << (*this).h <<endl;
}
//This is main.cpp file
#include <iostream>
#include "Hannah.h"
using namespace std;

int main(){
Hannah ho(23);
ho.printCrap();
}
43 changes: 43 additions & 0 deletions C++/50_51_cppBeginners.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//This is Sally.h file
#ifndef SALLY_H
#define SALLY_H

class Sally
{
public:
int num;
Sally();
Sally(int);
Sally operator+(Sally);
}
//This is Sally.cpp file
#include <iostream>
#include "Sally.h"
using namespace std;

Sally::Sally()
{
}

Sally::Sally(int a){
num = a;
}
Sally Sally::operator+(Sally aso){
Sally brandNew;
brandNew.num = num + aso.num;
return(brandNew);
}
//This is main.cpp file
#include <iostream>
#include "Sally.h"
using namespace std;

int main()
{
Sally a(34);
Sally b(21);
Sally c;
c=a+b;
cout << c.num << endl;

}
59 changes: 59 additions & 0 deletions C++/52_cppBeginners.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//This is Mother.h file
#ifndef MOTHER_H
#define MOTHER_H

class Mother
{
public:
Mother();
void sayName();
};

#endif // MOTHER_H

//This is Mother.cpp file
#include <iostream.h>
#include "Mother.h"
#include "Daughter.h"
using namespace std;

Mother::Mother()
{
}

void Mother::sayName(){
cout << "I am a RobnertsQ" << endl;
}

//This is Daughter.h file
#ifndef DAUGHTER_H
#define DAUGHTER_H

class Daughter: public Mother
{
public:
Daughter();
};

#endif // DAUGHTER_H

//This is Daughter.cpp file
#include <iostream.h>
#include "Mother.h"
#include "Daughter.h"
using namespace std;

Daughter::Daughter()
{
}
//This is main.cpp file
#include <iostream.h>
#include "Mother.h"
#include "Daughter.h"
using namespace std;

int main(){

Daughter tina;
tina.sayName();
}
Loading