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<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 |
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
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 | |
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
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"; |
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
class Animal{ | |
static int count=0; | |
Animal(){ | |
count++; | |
} | |
} | |
Animal *a[10]; | |
for(int i=0;i<10;i++) | |
a[i]=new Animal(); |
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
1.......................................................... | |
1 | |
1 2 | |
1 2 3 | |
1 2 3 4 | |
1 2 3 4 5 | |
#include<stdio.h> | |
#include<conio.h> |
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
// 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"); |
NewerOlder