🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

C++ programming by ASHOK PATE.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

freelance_Project available to buy contact on 8007592194 SR.NOProject NAME Technology 1 Online E-Learning Platform Hub React+Springboot+MySql...

freelance_Project available to buy contact on 8007592194 SR.NOProject NAME Technology 1 Online E-Learning Platform Hub React+Springboot+MySql 94 2 PG Mates / RoomSharing / Flat Mates React+Springboot+MySql 21 3 Tour and Travel management System React+Springboot+MySql 4 Election commition of India (online Voting System) React+Springboot+MySql 59 5 HomeRental Booking System React+Springboot+MySql 07 6 Event Management System React+Springboot+MySql 7 Hotel Management System React+Springboot+MySql 80 8 Agriculture web Project React+Springboot+MySql 9 AirLine Reservation System / Flight booking System React+Springboot+MySql.in 10 E-commerce web Project React+Springboot+MySql ys 11 Hospital Management System React+Springboot+MySql ra 12 E-RTO Driving licence portal React+Springboot+MySql 13 Transpotation Services portal ar React+Springboot+MySql 14 Courier Services Portal / Courier Management System React+Springboot+MySql ith 15 Online Food Delivery Portal React+Springboot+MySql w 16 Muncipal Corporation Management React+Springboot+MySql 17 Gym Management System de React+Springboot+MySql co 18 Bike/Car ental System Portal React+Springboot+MySql 19 CharityDonation web project React+Springboot+MySql 20 Movie Booking System React+Springboot+MySql freelance_Project available to buy contact on 8007592194 21 Job Portal web project React+Springboot+MySql 22 LIC Insurance Portal React+Springboot+MySql 23 Employee Management System React+Springboot+MySql 94 24 Payroll Management System React+Springboot+MySql 25 RealEstate Property Project React+Springboot+MySql 21 26 Marriage Hall Booking Project React+Springboot+MySql 27 Online Student Management portal React+Springboot+MySql 59 28 Resturant management System React+Springboot+MySql 29 Solar Management Project React+Springboot+MySql 07 30 OneStepService LinkLabourContractor React+Springboot+MySql 31 Vehical Service Center Portal React+Springboot+MySql 80 32 E-wallet Banking Project React+Springboot+MySql 33 Blogg Application Project React+Springboot+MySql 34 Car Parking booking Project React+Springboot+MySql.in 35 OLA Cab Booking Portal React+Springboot+MySql 36 Society management Portal React+Springboot+MySql ys 37 E-College Portal React+Springboot+MySql 38 FoodWaste Management Donate System React+Springboot+MySql ra 39 Sports Ground Booking React+Springboot+MySql ar 40 BloodBank mangement System React+Springboot+MySql 41 Bus Tickit Booking Project React+Springboot+MySql ith 42 Fruite Delivery Project React+Springboot+MySql 43 Woodworks Bed Shop React+Springboot+MySql w 44 Online Dairy Product sell Project React+Springboot+MySql 45 46 Online E-Pharma medicine sell Project FarmerMarketplace Web Project de React+Springboot+MySql React+Springboot+MySql co 47 Online Cloth Store Project React+Springboot+MySql 48 React+Springboot+MySql 49 React+Springboot+MySql 50 React+Springboot+MySql https://www.youtube.com/@codewitharrays 94 https://www.instagram.com/codewitharrays/ 21 59 07 https://t.me/codewitharrays Group Link: https://t.me/cceesept2023 80.in +91 8007592194 +91 9284926333 ys ra ar ith [email protected] w de co https://codewitharrays.in/project C++ Programming By Ashok Pate C++ Programming ---------------------------------------------------------------------------------------------- Basic concept of C program and C++ program #include //main->It is a user-defined function //calling main function is a job of OS. Hence main function is called as callback function // we cannot declare main function as static and constant //Bcoz main ko OS call karta hai bahar se call hai same scope nhi isliye static and const nhi kar sakte 94 //per project we can define only one main 21 //if we try to build c++ project without main then linker generates error 59 //In C++ executions starts from main, It is called calling function.It is designated to call other functions 07 // we cannot define main function inside function/structure/class void print( void ); // Global function declaration 80 int main() {.in //void print( void ); // local function declaration print( ); // function call ys return 0; } ra // called function void print( void )// function defination / Implementation ar { ith printf("Hello OM25 \n"); } w -------------------------------------------------------------------------------------------------------------------------- de #include //This is Global function defination no need of declaration co void print( void )// called function { printf("Hello OM25 \n"); } int main() // calling function { print( ); // function call return 0; } ------------------------------------------------------------------------------- page. 1 C++ Programming By Ashok Pate #include int sum( int a , int b ) //formal argument / a , b -> function parameters { int result; result = a + b; return result; } int main() { 94 int x = 10; int y = 20; 21 int result; 59 result = sum ( x , y ); // actual arg / function arguments 07 printf("Result : %d",result); //30 return 0; 80 } -------------------------------------------------------------------------------------------------------------------------- Swap cannot done.in #include void swap ( int x, int y) ys { ra int temp = x; x = y; ar y = temp; } ith int main() w { int a = 10; de int b = 20; co swap( a ,b ); // swap( a ,b ); ==> we are calling swap function by value // we are passing function argument by value // Function call by value printf("a : %d\n",a); // 10 printf("b : %d\n",b); //20 //swap cannot done bcoz by value function cannot pass two arguments. return 0; page. 2 C++ Programming By Ashok Pate } ------------------------------------------------------------------- What is the solution for above swap programm? Look at here Pass by address is the solution #include void swap ( int *x, int *y) { int temp = *x; *x = *y; *y = temp; } 94 int main() { 21 int a = 10; int b = 20; 59 07 swap( &a ,&b ); // function pass by address 80 printf("a : %d\n",a); //20 printf("b : %d\n",b); //10.in return 0; ys } ------------------------------------------------------------------- ra Without Structure ar #include ith int main() { w char name; de int empid; float salary; co printf("Name : "); scanf("%s",name); //name of array represent address itself //i.e we cannot use & address operator. printf("Empid : "); scanf("%d",&empid); page. 3 C++ Programming By Ashok Pate printf("Salary : "); scanf("%f",&salary); printf("Name : %s\n",name); printf("Empid : %d\n",empid); printf("Salary : %f\n",salary); return 0; } 94 Output:-Name : Ashok Empid :7 21 Salary : 10000 ----------------------------------------------------------- 59 Now by using Local Structure #include 07 int main() 80 { struct Employee // local structure {.in char name; int empid; ys float salary; }; ra struct Employee emp; ar // struct Employee : Data type // emp : variable/object ith printf("Name : "); w scanf("%s",emp.name); de printf("Empid : "); co scanf("%d",&emp.empid); printf("Salary : "); scanf("%f",&emp.salary); printf("Name : %s\n",emp.name); printf("Empid : %d\n",emp.empid); printf("Salary : %f\n",emp.salary); return 0; } Output:-Name : Ashok page. 4 C++ Programming By Ashok Pate Empid :7 Salary : 10000 ----------------------------------------------------------- Now by using Global Structure #include struct Employee // Global structure { char name; int empid; float salary; 94 }; //struct Employee *ptr = &emp 21 void print ( struct Employee *ptr ) { 59 printf("Name : %s\n",ptr->name); printf("Empid : %d\n",ptr->empid); 07 printf("Salary : %f\n",ptr->salary); } 80 int main() { struct Employee emp = { "Ketan", 1 , 1000.00f};.in // struct Employee : Data type ys // emp : variable/object print(&emp); // pass by address ra return 0; } Output:- Ketan, 1 , 1000.00 ------------------------------------------------------------------- ar Token ith Program is collection of statements. Statement is an instruction given to the computer. w Every instruction is made from token. de Token is basic unit of a program. Following are tokens in C: co 1. Identifier 2. Keyword 3. Constant / Literal 4. Operator 5. Punctuator/Separator Object Oriented Programming Structure Object-Oriented Programming‛ (OOP) was coined by Alan Kay. According to Alan Kay, the essential ingredients of OOP are: 1. Message passing 2. Encapsulation 3. Dynamic binding Grady Booch is inventor of UML( Unified Modelling Language ). According to Grady Booch, there are 4 major and 3 minor pillars of oops page. 5 C++ Programming By Ashok Pate Major Pillars Of OOPS Following are the four major pillars of oops: 1. Abstraction – To achieve simplicity 2. Encapsulation – To achieve data hiding 3. Modularity – To minimize module dependency 4. Hierarchy – To achieve reusability By major, we mean that a language without any one of these elements is not object oriented Minor Pillars Of OOPS 94 Following are the three minor pillars of oops: 21 1. Typing – To reduce maintenance of the system 2. Concurrency – To utilize hardware resources efficiently 59 3. Persistence – To maintain state of object on secondary storage. By minor, we mean that each of these elements is a useful, but not essential, to classify 07 language object oriented. 80 -------------------------------------------------------------------------------------------------------------------------- C++ Introduction.in C++ is a general-purpose programming language created by Bjarne Stroustrup in 1979. It is a pure C programming language in addition with Classes. ys It is object oriented programming language which is derived from C and Simula. ra Extension of C++ source file should be.cpp. Initial name of the language was “C with Classes”. ar C++ is standardized by the International Organization for Standardization(ISO). ith C++98, C++03, C++11, C++14, C++17, C++20, C++23 are C++ standards. Reference Website : https://en.cppreference.com/w/cpp w de C++ Programming: Language Keywords co Keywords are the reserved words that we can not use as identifier Reference : https://en.cppreference.com/w/cpp/keyword According to C++ 98, there are 74 keywords in C++. C++98 : 74 keywords C++11 : 10 keywords Data Type Data type of any variable decides 4 things: 1. Memory 2. Nature 3. Operation 4. Range Types of data type: page. 6 C++ Programming By Ashok Pate 1. Fundamental data types 2. Derived data types 3. User Defined data types 94 21 -------------------------------------------------------------------------------------------------------------------------- 59 C++ Concept Start 07 ------------------------------------------------------------------- struct Employee // Global structure 80 { char name; int empid;.in float salary; ys }; ra // Global function void accept_record( struct Employee *ptr) ar { ith printf("Name : "); scanf("%s",ptr->name); w de printf("Empid : "); scanf("%d",&ptr->empid); co printf("Salary : "); scanf("%f",&ptr->salary); } void print_record( struct Employee *ptr ) { printf("Name : %s\n",ptr->name); printf("Empid : %d\n",ptr->empid); printf("Salary : %f\n",ptr->salary); } page. 7 C++ Programming By Ashok Pate int main() // calling function { struct Employee emp; accept_record( &emp ); print_record ( &emp ); return 0; } 94  Here name,empid,salary are member of structure function  And the accept_record and print_record are the global function 21  Not member of structure still it can be access  Employee ke jo member hai usse jagah pe access hone chahiye jo 59 function 07 is structure ke member hai  name ,empid,salry jo is structure ko belong karte hai ussi ko 80 access hone chahiye --------------------------------------------------------------------------------------------------------------------------.in #include ys struct Employee // Global structure ra { private: ar char name; int empid; ith float salary; w de public: void accept_record( void ) co { printf("Name : "); scanf("%s",name); printf("Empid : "); scanf("%d",&empid); printf("Salary : "); scanf("%f",&salary); } page. 8 C++ Programming By Ashok Pate void print_record( void ) { printf("Name : %s\n",name); printf("Empid : %d\n",empid); printf("Salary : %f\n",salary); } }; int main() // calling function { struct Employee emp; 94 emp.accept_record( );//accept_record( &emp ); emp.salary = 0; 21 emp.print_record( );//print_record ( &emp ); 59 return 0; 07 } ->So we can change something here, first the function is written in a structure that is 80 why now they are members of structure and now they are not global functions this is global structure. -> second change is how to access them so now emp.accept_record() &.in emp.print_record() ys -> third change explicitly address/argument pass krne ki jrurat nhi hai accept_record or print_record ko. ra ->catch krte waqt bhi address operator use karne ki jarurat nhi internally implicitly ar perforem ho raha hai by this pointer. ->name salary empid update ya change karna hai tho sirf aur sirf structure member ith mai hi honi chahiye par aisa nhi ho raaha.when you change emp.salary=0; w ->so I want to restrict them c++ mai there is feature called access specifier ya visibility de lable => private ->private ka matlab ab structure ke member sirf structure mai hi change honge co ->Now name empid salary private ho gaye ab lenik private ke niche ke sare ke sare private ho gaye accept_record aur print_record bhi so I cannot used them in main for printing and accept ->So simply I do them public now they can be access and my name,empid,salary are private ->Now bcoz of private salary cannot change ->By default in c++ structure member are public. -> in C structure ke ander function nhi likh sakhte ->in c++ structure ke ander function likh sakhte hai bcoz of this pointer page. 9 C++ Programming By Ashok Pate ------------------------------------------------------------------- Access specifier 1.Private 2. Public 3.Protected (we can see in inheritors) If we want to control visibility of the members of a structure/class then we should use 94 access specifier. 21 Private, protected and public are access specifiers in C++. In C++, structure members are by default public and class members are by default private. 59 ------------------------------------------------------------------------------------------------------------------------ 07 Class Concept C++:- class members are by default private. #include 80.in class Employee { ys private: char name; // 32 // Data members / field / attribute / ra property ar int empid; // 4 float salary; // 4 ith //member functions/method/operation/behaivour w public: de void accept_record( void ) { co printf("Name : "); scanf("%s",name); printf("Empid : "); scanf("%d",&empid); printf("Salary : "); scanf("%f",&salary); } page. 10 C++ Programming By Ashok Pate void print_record( void ) { printf("Name : %s\n",name); printf("Empid : %d\n",empid); printf("Salary : %f\n",salary); } }; int main() // calling function { int num; 94 Employee emp; // Instantiation //classname Identifier 21 // emp ==> variable // Instance 59 // object // Ketan 1 1000 07 emp.accept_record( );// message passing 80 //accept_record( &emp ); emp.print_record( );//message passing // print_record ( &emp );.in return 0; ys } ->Class mai Data member ko private krenge member function ko nhi ra ->structure ka object banate waqt struct keyword dena padta tha ar Struct Employee emp; ->Class ka object banate waqt class keyword dena optional hai ith Employee emp; or class Employee emp; ->object ke ander sirf aur sirf data type ko space milti hai w ->member function are behaviour de ------------------------------------------------------------------- co Data member A variable declared inside class/class scope is called data member. Data member is also called as field/attribute/property. Only data member get space once per object and according to order of their declaration inside class. Only by understanding problem statement, we can decide data members inside class/structure. page. 11 C++ Programming By Ashok Pate ------------------------------------------------------------------ Member function A function defined/implemented inside class/class scope is called 94 member function. Member function is also called as 21 method/operation/behavior/operation. Member function do not get space inside object. All the objects 59 of same class share single copy of member function 07 80.in ys ------------------------------------------------------------------- ra Class ar class is a keyword in C++. It is a collection of data member and member function. ith It is a basic unit of encapsulation. Class can contain: w Data members de 1. Non static data members 2. Static data members co Member Functions 1. Non static member functions 2. Static member functions Nested Types Class (not in syllabus) Some member functions are special: under certain circumstances they are defined by the compiler: 1. Constructor 2. Destructor 3. Copy constructor 4. Assignment operator function page. 12 C++ Programming By Ashok Pate A class from which, we can create object is called concrete class. In words, we can instantiate concrete class. (instantiate means creating object) A class from which, we can not create object is called abstract class. In words, we can not instantiate abstract class. Example:- Clsss Test //abstract class { public: Virtual void f1()=0; //abstract method }; A member function of a class, which is having a body is called concrete method. 94 A member function of a class, which do not have a body is called abstract method. 21 59 Instance and Instantiation Variable or instance of a class is called object. 07 Ex. emp is a variable/instance/object 80 Process of creating object from a class is called instantiation. (Object create krne ko hi instantiation bolte hai) Syntax : 1. class ClassName identifier; //or 2. ClassName.in identifier; As shown above, during instantiation, use of class keyword is optional. Example: Complex c1; ys Here class Complex is instantiated and name of instance is c1. Global variable/Local Variable/Function Parameter / Member ra function do not get space inside object ar object ke ander sirf aur sirf data member ko hi space milti hai. ith Message Passing Process of calling member function on object is called message w passing de Consider following example: co page. 13 C++ Programming By Ashok Pate ------------------------------------------------------------------- Scope resolution Operator ->Now in this program member function definition written outside the class function and declaration of member function given in the class. -> that’s why we used here :: scope resolution operator for member function and it is denotes as(::) #include class Employee { 94 // Data members / field / attribute / property private: 21 char name; // 32 int empid; // 4 59 float salary; // 4 07 //member functions/method/operation/behaivour 80 public: // declaration.in void accept_record( void ); void print_record( void ); ys }; ra ar // :: ==> scope resolution operator // member function defined outside the class ith // defination void Employee :: accept_record( void ) w { de printf("Name : "); scanf("%s",name); co printf("Empid : "); scanf("%d",&empid); printf("Salary : "); scanf("%f",&salary); } page. 14 C++ Programming By Ashok Pate void Employee :: print_record( void ) { printf("Name : %s\n",name); printf("Empid : %d\n",empid); printf("Salary : %f\n",salary); } int main() // calling function { int num; Employee emp; // Instantiation 94 //classname Identifier // emp ==> variable 21 // Instance // object 59 // Ketan 1 1000 07 emp.accept_record( );// message passing 80 //accept_record( &emp ); emp.print_record( );//message passing // print_record ( &emp );.in return 0; ys } ------------------------------------------------------------------- ra Storage Classes ar Following are the storage classes in C/C++: 1. auto 2. static 3. extern 4. Register ith Storage class decides scope of variable and function and lifetime of the variable. Scope in C++ w Scope decides region/area/boundary where we can access de variable/function. Following are the scope in C++: co 1. Block scope 2. Function scope 3. Prototype scope 4. Class Scope 5. Namespace Scope 6. File Scope 7. Program Scope ------------------------------------------------------------------- page. 15 C++ Programming By Ashok Pate Scope represent in below program. #include int num5 = 60; // program scope static int num6 = 50; // file scope namespace na { int num4 = 40; // namespace scope class test { 94 int num3; // class scope }; 21 } int main() 59 { 07 int sum( int num1 , int num2);// prototype scope int num2 = 20; // local variable // function scope 80 { int num1 = 10; // local variable ==> block scope }.in } ------------------------------------------------------------------- ys Lifetime in C++ Lifetime represents existence of variable/object inside RAM. ra Following are the lifetimes in C++: ar 1. Automatic lifetime 2. Static lifetime ith 3. Dynamic lifetime ------------------------------------------------------------------------------------------------------------------------- w ->I want to used global variable in main scope for print I need to de used scope resolution operator(::). ->Scope resolution operator print global variable not local co variable. Inside same scope, we can not give same name to the multiple variables. But name of local variable and global variable can be same. If name of local variable and global variable is same then preference is always given to the local variable. In C++, using scope resolution operator, we can access value of global variable inside function. page. 16 C++ Programming By Ashok Pate #include int num1 =10 ; // program scope int main() { int num1 = 20; // function scope printf("num1 : %d\n",::num1); //10 printf("num2 : %d\n",num1);// 20 { int num1 = 30; printf("num1 : %d\n",::num1); //10 printf("num1 : %d\n",num1); //30 94 } return 0; 21 } ------------------------------------------------------------------- 59 Namespace Concept 07 What is the Need of Namespace? 80 ->for example two compnies of oracle and mysql.i want to fetch data from database from this companies connector but the class name of this connector is same connection so,that why c++ complier may get.in confused which connection is either of oracle or mysql so to avoid fixed this type of problem in c++ there is concept of Namespace. ys 1. To avoid name clashing/collision/ambiguity. 2. To group functionally related / equivalent types together ra Example diagram refer:- ar ith w de co ------------------------------------------------------------------- page. 17 C++ Programming By Ashok Pate Namespace concept by program #include namespace na { int num1 = 10;// OK // namespace scope } int num1=50; int main() { printf("Num1 : %d\n",na::num1); //10 94 printf("Num1 : %d\n",num1); //50 21 return 0; 59 } ->Main ko hum namespace main hi likh sakate linker error give. 07 ------------------------------------------------------------------- If name of the namespaces are different then name of members of 80 namespace may/may not be same #include namespace na.in { ys int num1 = 10;// OK // namespace scope int num3 = 30; ra } namespace nb ar { ith int num2 = 20;// OK // namespace scope int num3 = 40; w } de int main() co { printf("Num1 : %d\n",na::num1); //10 printf("Num3 : %d\n",na::num3); //30 printf("Num2 : %d\n",nb::num2); //20 printf("Num3 : %d\n",nb::num3); //40 return 0; } ------------------------------------------------------------------- page. 18 C++ Programming By Ashok Pate If name of the namespaces are same then name of members of namespace can not be same.#include namespace na { int num1 = 10;// OK // namespace scope int num3 = 30; } namespace na { int num2 = 20;// OK // namespace scope 94 int num3 = 40;//not ok } 21 int main() { 59 printf("Num1 : %d\n",na::num1); //10 07 printf("Num3 : %d\n",na::num3); //error 80 printf("Num2 : %d\n",na::num2); //20 printf("Num3 : %d\n",na::num3); //error.in return 0; } ys ->in this program error give bcoz ->Namespace ke name same hai tho chalata hai but it treated like ra below ar thats why 2 same variable num3 give error. namespace na ith { int num1 = 10;// OK // namespace scope w int num3 = 30; //error same variable de int num2 = 20;// OK // namespace scope int num3 = 40; //error same variable co } ------------------------------------------------------------------- Now in this case same namespace but different variable and its work observe output in this program #include namespace na { int num1 = 10;// OK // namespace scope int num3 = 30; } page. 19 C++ Programming By Ashok Pate namespace na { int num2 = 20;// OK // namespace scope int num4 = 40; } int main() { printf("Num1 : %d\n",na::num1); //10 94 printf("Num3 : %d\n",na::num3); //30 21 printf("Num2 : %d\n",na::num2); //20 printf("Num4 : %d\n",na::num4); //40 59 07 return 0; } 80 ------------------------------------------------------------------- We can define namespace inside another namespace. It is called nested namespace..in #include ys int num1 = 100; // program scope namespace na // top level namespace ra { ar int num2 = 20; // namespace scope namespace nb // nested namespace ith { w int num3 = 30; } de } int main() co { printf("Num1 : %d\n",na::nb::num3); //30 printf("Num2 : %d\n",na::num2); //20 printf("Num1 : %d\n",::num1); //100 return 0; } ------------------------------------------------------------------- page. 20 C++ Programming By Ashok Pate Now my requirement is I want to used one variable many time so every time scope resolution operator is must but I want to avoid that so the thing is in c++ is using directive. Simply used using namespace na and after that you didn’t need of scope resolution operator.Refer below program then. If we want to use members of namespace frequently then we should use using directive #include namespace na { 94 int num1 = 10; } 21 int main() { 59 using namespace na; 07 printf("Num1 : %d\n",num1); // 10 return 0; 80 } ------------------------------------------------------------------- Now, But namespace aur main directive mai same variable honga tho.in using directive kam nhi karenga you have to give scope resolution ys operator. ra Observe below program output. ar #include namespace na ith { int num1 = 10; w } de int main() { co int num1 = 20; using namespace na; printf("Num1 : %d\n",num1); //20 printf("Num1 : %d\n",na::num1); //10 } ----------------------------------------------------------------- page. 21 C++ Programming By Ashok Pate #include namespace na { int num1 = 10; } using namespace na; void show_record( void ) { //printf("Num1 : %d\n",na::num1); without using directive 94 //using namespace na; printf("Num1 : %d\n",num1);//10 //using directive global 21 } void print_record( void ) 59 { //printf("Num1 : %d\n",na::num1); without using directive 07 80 //using namespace na; printf("Num1 : %d\n",num1); //10 //using directive global.in } void display_record( void ) ys { //printf("Num1 : %d\n",na::num1); without using directive ra //using namespace na; ar printf("Num1 : %d\n",num1); //10 //using directive global } ith int main() w { de ::show_record(); ::print_record( ); co ::display_record( ); return 0; } ->Here all functions are global thts why when we call function that time use :: scope resolution operator. ------------------------------------------------------------------------------- page. 22 C++ Programming By Ashok Pate Points to remember about namespace We can give same /different name to the namespaces. To access members of namespace either we should use :: operator / using directive. We can not define namespace inside function/class. It should be global / it should be inside another namespace. We can not define main function inside namespace. It must be member of global namespace. We can not create object of namespace. It is used for grouping. std is standard namespace in C++. Generally name of the namespace should be in lower case. 94 ------------------------------------------------------------------- Cin , cout , cerr , clog concept 21 59 Standard Streams Of C++ Stream is a an abstraction(object) which is used to 07 produce(write) and consume(read) data from source to destination. Console = Keyboard + Monitor. 80 Following are the standard streams of C++ that is associated with console: 1. cin : input stream represents keyboard 2. cout : output stream represents monitor.in 3. cerr : Unbuffered standard error stream 4. clog : Buffered standard error stream ys ra ar ith w de co ->In C++ there standard library for cin,cout,cerr,clog i.e header file. ->Cin is used to take input from user like scanf. ->Cout is used to print data on moniter like printf. ------------------------------------------------------------------- page. 23 C++ Programming By Ashok Pate COUT cout stands for character output. It is standard output stream of C++ which represents monitor. In other words, if we want to print state of object on console/monitor then we should use cout. cout is object of ostream class and ostream is nickname/alias of basic_ostream class. typedef basic_ostream ostream; cout is declared as extern object inside std namespace ( hence std::cout ) and std namespace is declared in header file. cout is not a function hence to read data from keyboard we must use insertion(

Use Quizgecko on...
Browser
Browser