-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f529eb9
commit 0596a7f
Showing
28 changed files
with
465 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include<iostream> | ||
using namespace std; | ||
class area_circle{ | ||
int r,area; | ||
public: | ||
void read_data(){ | ||
cin>>r; | ||
} | ||
|
||
void publish_data() | ||
{ | ||
cout<<area; | ||
} | ||
}; | ||
|
||
|
||
class volume:public area_circle | ||
{ | ||
int x; | ||
public: | ||
void get_data(){ | ||
} | ||
void show_data(){ | ||
|
||
} | ||
}; | ||
|
||
int main(){ | ||
volume B; | ||
B.get_data(); | ||
B.show_data(); | ||
B.read_data(); | ||
B.publish_data(); | ||
return 0; | ||
} |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include<iostream> | ||
#include<string.h> | ||
using namespace std; | ||
class student{ | ||
private: | ||
int roll; | ||
char name[30]; | ||
|
||
public: | ||
student(int x, char y[]) // parameterized constructor function | ||
{ | ||
roll= x; | ||
strcpy(name,y) ; | ||
} | ||
void show_data(){ | ||
cout<<"\n Roll no :"<<roll; | ||
cout<<"\n Name :"<<name; | ||
} | ||
}; | ||
|
||
int main(){ | ||
//student s; // constructor function runs at the time of object creation | ||
|
||
student s(10,"Manan"); // implicit call | ||
|
||
student s1 = student(20,"Ramji"); // explicit call | ||
s.show_data(); | ||
s1.show_data(); | ||
return 0; | ||
} |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include<iostream> | ||
#include<string.h> | ||
using namespace std; | ||
class student{ | ||
private: | ||
int roll; | ||
char name[30]; | ||
|
||
public: | ||
student(int x=10, char y[]="Sumit Singh") // parameterized constructor with default values | ||
{ | ||
roll= x; | ||
strcpy(name,y) ; | ||
} | ||
void show_data(){ | ||
cout<<"\n Roll no :"<<roll; | ||
cout<<"\n Name :"<<name; | ||
} | ||
}; | ||
|
||
int main(){ | ||
|
||
//student s; // constructor function runs at the time of object creation | ||
student s(30,"Hitesg"); | ||
s.show_data(); | ||
return 0; | ||
} |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include<iostream> | ||
#include<string.h> | ||
using namespace std; | ||
class student{ | ||
public: | ||
student(){ | ||
cout<<"\n I am constructor" ; | ||
} | ||
~student(){ | ||
cout<<"\n Inside destrctor"; | ||
} | ||
}; | ||
|
||
int main(){ | ||
|
||
student s; | ||
{ | ||
student s1; | ||
} | ||
student s2; | ||
return 0; | ||
} |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include<iostream> | ||
#include<string.h> | ||
using namespace std; | ||
class student{ | ||
private: | ||
int roll; | ||
char name[30]; | ||
|
||
public: | ||
|
||
student(){ | ||
roll=20; | ||
strcpy(name,"Rakesh"); | ||
} | ||
|
||
student(int x, char y[]) // parameterized constructor with default values | ||
{ | ||
roll= x; | ||
strcpy(name,y) ; | ||
} | ||
|
||
void show_data(){ | ||
cout<<"\n Roll no :"<<roll; | ||
cout<<"\n Name :"<<name; | ||
} | ||
}; | ||
|
||
int main(){ | ||
|
||
//student s; // constructor function runs at the time of object creation | ||
student s(40,"rajesh mandal"); | ||
s.show_data(); | ||
return 0; | ||
} |
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
How to learn and then earn using C++ | ||
This is my second line of text | ||
This is third line having tab and another spacing chars |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
ofstream handa; | ||
handa.open("demo.txt"); | ||
handa<<"How to learn and then earn using C++"; | ||
handa<<"\nThis is my second line of text"; | ||
handa<<"\n This is third line having \t tab and another spacing chars"; | ||
handa.close(); | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
ifstream object; | ||
char name[300]; | ||
object.open("demo.txt"); | ||
object>>name; // read one word at a time | ||
cout<<"\n Entered Name :"<<name; | ||
object.close(); | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
ifstream object; | ||
char name[300]; | ||
object.open("demo.txt"); | ||
object.getline(name,300); | ||
cout<<"\n Entered Value :"<<name; | ||
object.close(); | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
ifstream object; | ||
char name[300]; | ||
object.open("demo.txt"); | ||
|
||
object.getline(name,300); | ||
cout<<"\n Entered Value :"<<name; | ||
object.getline(name,300); | ||
cout<<"\n Entered Value :"<<name; | ||
object.getline(name,300); | ||
cout<<"\n Entered Value :"<<name; | ||
|
||
object.close(); | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// file read char wise + EOF function | ||
|
||
|
||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
ifstream object; | ||
char ch; | ||
object.open("file_read_eof.cpp"); | ||
|
||
while(!object.eof()) | ||
{ | ||
object.get(ch); | ||
cout<<ch; | ||
} | ||
|
||
object.close(); | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// file read and using EOF function | ||
|
||
|
||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
ifstream object; | ||
char name[300]; | ||
object.open("demo.txt"); | ||
|
||
while(!object.eof()) | ||
{ | ||
object.getline(name,300); | ||
cout<<name; | ||
} | ||
|
||
object.close(); | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// file read char wise + EOF function | ||
|
||
|
||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
ifstream object; | ||
char ch; | ||
object.open("file_read_eof.cpp"); | ||
|
||
while( object.get(ch)) // checking end of file using file object | ||
cout<<ch; | ||
|
||
|
||
object.close(); | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// file read char wise + EOF function | ||
|
||
|
||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
ifstream object; | ||
char ch; | ||
object.open("file_read_eof.cpp"); | ||
|
||
while(object) // checking end of file using file object | ||
{ | ||
object.get(ch); | ||
cout<<ch; | ||
} | ||
|
||
object.close(); | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// program to find out total no of words in a text file | ||
#include<fstream> | ||
#include<iostream> | ||
using namespace std; | ||
int main(){ | ||
ifstream fin; | ||
fin.open("demo.txt"); | ||
char word[100]; | ||
int count=0; | ||
while(fin){ | ||
fin>>word; | ||
count++; | ||
} | ||
fin.close(); | ||
cout<<"\nTotal words :"<<count; | ||
return 0; | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include<iostream> | ||
using namespace std; | ||
class area_circle{ | ||
int r,area; | ||
public: | ||
void read_data(){ | ||
cin>>r; | ||
} | ||
|
||
void publish_data() | ||
{ | ||
cout<<area; | ||
} | ||
}; | ||
|
||
|
||
class volume:public area_circle // using public | ||
{ | ||
int x; | ||
public: | ||
void get_data(){ | ||
} | ||
void show_data(){ | ||
|
||
} | ||
}; | ||
|
||
int main(){ | ||
volume B; | ||
B.get_data(); | ||
B.show_data(); | ||
B.read_data(); | ||
B.publish_data(); | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include<iostream> | ||
using namespace std; | ||
class mukul | ||
{ | ||
private: | ||
int a; | ||
public: | ||
int b; | ||
protected: | ||
int c; | ||
}; | ||
|
||
int main(){ | ||
mukul obj; | ||
obj.a=10; | ||
obj.b=20; | ||
obj.c=30; | ||
return 0; | ||
} |
Oops, something went wrong.