Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Stream Overloading

// #include <bits/stdc++.h>
// #include<chrono>
// using namespace std;
// auto start = chrono::steady_clock::now();

// int main(){
//     cout<<"My name is Devil"<<endl;
//     auto end= chrono::steady_clock::now();
//     auto diff = end - start;
//     cout<<chrono::duration<double,milli>(diff).count()<<" ms"<<endl;
//     return 0;
// }

// #include <bits/stdc++.h>
// #include<chrono>
// using namespace std;
// auto start = chrono::steady_clock::now();

// int main(){
    
//     cout<<"Hello how are u Akash kumar jiii"<<endl;
//     auto end= chrono::steady_clock::now();
//     auto diff = end - start;
//     cout<<chrono::duration<double,milli>(diff).count()<<"ms"<<endl;
//     return 0;
// }

#include<bits/stdc++.h>
#include<stdexcept>
#include<chrono>
using namespace std;
auto start = chrono::steady_clock::now();

class Person{
	string name;
	int age;
	public:	
		Person(){
			this->name = "No name";
			this->age = 0;
		}
		friend ostream &operator <<(ostream &output , Person &p);
		friend istream &operator >>(istream &input , Person &p);
};

ostream &operator <<(ostream &output , Person &p){
	output<<"Who is Devil "<<endl;
	output<<"My name is "<<p.name<<" My age is "<<p.age<<endl;
	return output;
}
istream &operator >>(istream &input , Person &p){
	cin>>p.name>>p.age;
	return input;
}

int main(){
	cout<<"Enter the name "<<endl;
	Person ak;
	cin>>ak;
	cout<<ak;

    auto end= chrono::steady_clock::now();
    auto diff = end - start;
    cout<<chrono::duration<double,milli>(diff).count()<<" ms"<<endl;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: How to clear keyboard buffer c++ 
Cpp :: c++ call overriden method from constructor 
Cpp :: convert char to C 
Cpp :: c pointer syntax 
Cpp :: ala vida 
Cpp :: how the theam are store in database 
Cpp :: beecrowd problem 1004 solution 
Cpp :: codeform 
Cpp :: Jython Java Python 
Cpp :: compile c++ program 
Cpp :: In-range Adder 
Cpp :: ue4 log 
Cpp :: 2d stl array 
Cpp :: C++ Point to Every Array Elements 
Cpp :: qt/c++ exception handler 
Cpp :: Smooth Poti values on Arduino 
Cpp :: user inptu in cpp 
Cpp :: multiply two arbitrary integers a and b (a greater than b) 
Cpp :: In every C++ program: 
Cpp :: how to implement stack 
Cpp :: converter c++ to c 
Cpp :: Set Specific Time in youtube Video url 
Cpp :: use of strtok 
Cpp :: call by value in c++ 
Cpp :: c++ generate random number upper and lower bound 
C :: fahrenheit to celsius formula 
C :: how to use gets after scanf 
C :: how to print helloq world in c 
C :: is 33 prime number 
C :: graphics in c 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =