This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
// Base Class | |
class Parent { | |
public: | |
void print(){ | |
cout << "Parent Print Function" << endl; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Complex{ | |
private: | |
int real, imag; // imag for imagination | |
public: | |
Complex(int r = 0, int i = 0) {real = r; imag = i;} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Numbers { | |
public: | |
// function with int parameter | |
void num(int x){ | |
cout << "Value of x is: "<< x << endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class printInfo { | |
public: | |
void print(int i){ | |
cout << "Int: " << i << endl; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++ Inheritance | |
#include <iostream> | |
#include <bits/stdc++.h> | |
using namespace std; | |
// Base Class | |
class Parent{ | |
public: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// c++ oop protected access modifier | |
#include <iostream> | |
using namespace std; | |
// defining a class | |
class Parent { | |
protected: // we defined that this class data members will be protected | |
int number_protected; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// c++ oop private access modifier | |
#include <iostream> | |
using namespace std; | |
// defining a class | |
class Circle { | |
private: // we defined that this class data members will be private | |
double radius; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// c++ oop private access modifier | |
#include <iostream> | |
using namespace std; | |
// defining a class | |
class Circle { | |
private: // we defined that this class data members will be private | |
double radius; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// c++ oop public access modifier | |
#include <iostream> | |
using namespace std; | |
// defining a class | |
class Circle { | |
public: // we defined that this class data members will be public | |
double radius; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
class CarMake { | |
public: | |
string m_make; | |
string m_model; | |
int m_year; |