A

@Adarsh1999

basics Car.cpp

C++
3 years ago
#include "Car.h" #include <iostream> int Car::totalCount = 0; Car::Car():Car(0) { std::cout << "Car()" << std::endl; } Car::Car(float amount):Car(amount, 0) { std::cout << "Car(float)" << std::endl;

structure uses

C++
3 years ago
#include <iostream> struct Point { int x; int y; }; void DrawLine(int x1, int y1, int x2, int y2) { } //More natural and easy to understand void DrawLine(Point start, Point end) {

pointer array

C++
3 years ago
#include <iostream> #include <cstring> int main() { using namespace std; int *arr = new int[20]; // or {3,5,6,7,8,} for(int i=0;i<5;i++){ cin >> arr[i] ; } for(int i=0;i<5;i++){

Malloc

C++
3 years ago
#include <iostream> int main() { using namespace std; int *ptr=new(int);//or new(6); 6 is value *ptr=6; cout<<*ptr<<endl; delete ptr; ptr = nullptr; }

namespace 2

C++
3 years ago
#include <iostream> namespace Avg { float Calculate(float x, float y) { return (x + y) / 2; } } namespace Basic { float Calculate(float x, float y) {

Namespace

C++
3 years ago
#include <iostream> namespace ad{ int cal(int a,int b){ int res=a+b; return res; } int cal(int a){ int res=a+a;

inline fn

C++
3 years ago
#include <iostream> inline int Square (int x) {// this fn replaces the while code of square(val+1); return x* x; } //#define Square (x) x*x will get some buggs here int main() { using namespace std; int val = 5;

Function overload

C++
3 years ago
#include <iostream> int add(int a,int b){ int sum=a+b; return sum; } float add(float a,float b){ float sum=a+b; return sum;

Array begin end

C++
3 years ago
#include <iostream> int main() { using namespace std; int arr[] = {1,2,3,4,5 }; //for (int i = 0; i < 5; i++) { // cout << arr[i] << " "; //} for (auto x : arr) { cout << x << " ";

swap with reference

C++
3 years ago
#include <iostream> /*void Swap (int *x, int *y) { int temp = x; *x = *y; *y = temp; }*/ void Swap(int&x, int&y) { int temp = x;

Reference

C++
3 years ago
#include <iostream> int main() { using namespace std; //Referent int x = 10; //Reference int &ref= x; ref = 6; cout << "x:" << x << endl; cout << "ref:" << ref << endl;

null ptr

C++
3 years ago
#include <iostream> int main() { using namespace std; int x = 10; cout << &x << "\n"; void *ptr = nullptr; cout << ptr << "\n"; return 0; }

array basics

C++
3 years ago
#include <iostream> using namespace std; int main() { //char arr[30]{"hi im adarsh"}; char arr[30]{}; //cin >> arr; cin.getline(arr,10,'\n'); cout << arr << endl;

polymorphism

C++
3 years ago
/* in school student, in home son, in bus passenger, in shoping mall customer */ #include <iostream> using namespace std; // Base class class Animal { public: void animalSound() {

Swap 2 no

C++
3 years ago
#include<iostream> class clsswap{ public: void swap(int*,int*); }; void clsswap::swap(int *a,int *b){ int tmp; tmp=*a;

sum of nos

C++
3 years ago
#include<iostream> int main(){ int a,sum=0; while(true){ std::cin>>a; if(a==0){ break;

Average no

C++
3 years ago
#include <iostream> int main() { int a,b,c,avg; std::cin>>a>>b>>c; avg=(a+b+c)/3; std::cout<<"avg is : "<<avg; }

Basics

C++
3 years ago
#include<iostream> using namespace std; int main(){ cout<<"hello world"<<endl; } /* This program begins by including the "iostream" library, which provides input/output

Multiple Inheritance

C++
3 years ago
/*Multiple Inheritance A class can also be derived from more than one base class, using a comma-separated list:*/ #include<iostream> #include<string> using namespace std; // Base class class MyClass {

Multilevel Inheritance

C++
3 years ago
/*Multilevel Inheritance A class can also be derived from one class, which is already derived from another class. In the following example, MyGrandChild is derived from class MyChild (which is derived from MyClass).*/ #include<iostream>