Skip to content

Instantly share code, notes, and snippets.

View webber2408's full-sized avatar
🎯
Focusing

Rahul Sharma webber2408

🎯
Focusing
View GitHub Profile
@webber2408
webber2408 / c1_class_object.cpp
Created April 10, 2020 07:42
Class and Object example
#include<iostream>
using namespace std;
class Country{
public:
string name;
int populationCount;
void storeCountryInformation(string s, int n){
name = s;
@webber2408
webber2408 / c2_constructor_destructor.cpp
Last active April 10, 2020 10:53
Constructor, Destructor and this keyword
#include<iostream>
using namespace std;
class Country{
public:
string name;
int populationCount;
//Constructor
Country(){
@webber2408
webber2408 / c3_default_copy_constructor.cpp
Created April 11, 2020 10:20
Default Copy Constructor
#include<iostream>
using namespace std;
class Country{
public:
string name;
int populationCount;
//Parameterized Counstructor
Country(string s, int n){
@webber2408
webber2408 / c4_user_defined_copy_constructor.cpp
Last active April 11, 2020 14:34
User defined copy constructor
#include<iostream>
using namespace std;
class Country{
public:
string name;
int populationCount;
int *stateCount;
Country(){
#include<iostream>
using namespace std;
class Country{
public:
string name;
int populationCount;
static int countryCount;
void setCountryDetails(string s, int n){
@webber2408
webber2408 / c6_structs.cpp
Created April 12, 2020 06:26
Structs in C++
#include<iostream>
using namespace std;
struct Country{
string name;
int populationCount;
Country(string s, int n){
name = s;
populationCount = n;
@webber2408
webber2408 / c7_enum.cpp
Created April 12, 2020 08:18
C++ Enumerations
#include<iostream>
using namespace std;
enum Direction {North, South, East, West} dir;
enum Gender {Male, Female};
int main(){
//Example 1
dir = East;
@webber2408
webber2408 / c8_friend_functions.cpp
Created April 13, 2020 07:13
C++ Friend Functions
#include<iostream>
using namespace std;
class Country{
private:
string name;
int populationCount;
public:
Country(string s, int n){
@webber2408
webber2408 / c9_friend_class.cpp
Created April 13, 2020 07:28
C++ Friend Classes
#include<iostream>
using namespace std;
class Country{
private:
string name;
int populationCount;
public:
@webber2408
webber2408 / o1_inheritance.cpp
Created May 18, 2020 12:28
Inheritance Example
#include<bits/stdc++.h>
using namespace std;
class Person{
private:
string name;
int age;
public:
Person(string name, int age): name{name}, age{age}{