C++ Tutorials

How to Use Read and Write Methods in C++ 0

How to Use Read and Write Methods in C++

Program 1 // read write method (How to store object in file) #include<iostream> #include<fstream> #define clrscr() system(“cls”) using namespace std; class Employee { private : int empid; char name[20]; char dname[20]; int salary; public:...

C++ Program For get vs getline 0

C++ Program For get vs getline

Program 1 // get and getline method #include<iostream> #include<fstream> #define clrscr() system(“cls”) using namespace std; int main() { char name[20]; char college[20]; clrscr(); cout<<“\nEnter your Name:”; cin.getline(name,20); cout<<“\nEnter your College Name:”; cin.getline(college,20); cout<<“\nName: “<<name;...

How to Open File Using Open Method in C++ 0

How to Open File Using Open Method in C++

Program 1 // open file using Open Method for write #include<iostream> #include<fstream> #define clrscr() system(“cls”) using namespace std; int main() { clrscr(); fstream fout; char name[20]; char city[20]; char college[20]; fout.open(“g://cppdata/student.txt”,ios::out); cout<<“Enter Name: “;...

How to Open a File Using Constructor in C++ 0

How to Open a File Using Constructor in C++

Program 1 // open file using constructor #include<iostream> #include<fstream> #define clrscr() system(“cls”) using namespace std; int main() { char name1[50]; clrscr(); fstream fout(“f://cppfile/City.txt”,ios::app); //using constructor // cout<<“Enter Name of City: “; // cin>>name; //...

C++ Program For Aggregation 0

C++ Program For Aggregation

Program 1 // Program for Aggrigation(Has A Relation) #include<iostream> #include<string.h> #define clrscr() system(“cls”) using namespace std; class Personal { public: char name[50]; char address[50]; int mobile; public: Personal(char name[],char address[],int mobile) { strcpy(this->name,name); strcpy(this->address,address);...

How To Use sizeof an Operator in C++ 0

How To Use sizeof an Operator in C++

Program 1 // Program for Sizeof Operator #include<iostream> #define clrscr() system(“cls”) using namespace std; class Test1 { private: double d1; double d2; double d3; int n; }; class Test2:public Test1 { }; int main()...

C++ Program For Hybrid Inheritance 0

C++ Program For Hybrid Inheritance

Program 1 // Program for hybridge inheritance with multilevel and multiple #include<iostream> #define clrscr() system(“cls”) using namespace std; class Student { protected: int rno; char name[50]; public: void getStudent() { cout<<“\n Enter roll no”;...

C++ Program For Multiple Inheritance 0

C++ Program For Multiple Inheritance

Program 1 // Program for method overloading #include<iostream> #define clrscr() system(“cls”) using namespace std; class Student { protected: int rno; char name[50]; public: // Student() // { // cout<<“\n constructor of student class”; //...

C++ Program For Virtual Function 0

C++ Program For Virtual Function

Program 1 // Program for Virtual Function #include<iostream> #include<string.h> #define clrscr() system(“cls”) using namespace std; class Base // Abstract class { public: void virtual display()=0; }; class Derived:public Base { public: void display() {...