Skip to content

Instantly share code, notes, and snippets.

#include<memory> // in memoty library
auto_ptr<int> a(new int);
auto_ptr<int> b;
*a=10;
cout<<a.get()<<endl; // 10
b=a; // pointer authority transferred to b
int *p=new int;
cout<<(*p)<<endl; // No problem
delete p; // memory pointed by p is de allocated
cout<<(*p)<<endl; // errot due to dangeling pointer
auto a=3.2 + 5; // a=8.2
// auto in function
auto add(int a,int b){
return a+b;
}
a=add(1,2); // a=3
string s="abcdssdfshfbj";
class Animal{
static int count=0;
Animal(){
count++;
}
}
Animal *a[10];
for(int i=0;i<10;i++)
a[i]=new Animal();
1..........................................................
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
#include<stdio.h>
#include<conio.h>
// data in file is like
// No. Name Mark1 Mark2 Mark3
// Use full file path instead of just file name if any error occurs !!
function menu()
disp("1 : Read File");
disp("2 : Write File");
disp("3 : Search in File");