3 SEM - Object Oriented Programming Using C++ NOTES PDF
Document Details
![QuaintNephrite1087](https://quizgecko.com/images/avatars/avatar-5.webp)
Uploaded by QuaintNephrite1087
New Horizon College of Engineering
Tags
Summary
These are lecture notes for a 3rd semester course on object-oriented programming using C++. The document covers topics like C++ overview, function declarations and calls, and other related concepts.
Full Transcript
NEW HORIZON COLLEGE, MARATHALLI BANGALORE – 560103 Subject Code: BCA 303T Subject Name: Object Oriented Programming Using C++ Name of the Faculty: NagarajuKilari, Sr. Asst.Prof&HOD-BCA 1|P age ...
NEW HORIZON COLLEGE, MARATHALLI BANGALORE – 560103 Subject Code: BCA 303T Subject Name: Object Oriented Programming Using C++ Name of the Faculty: NagarajuKilari, Sr. Asst.Prof&HOD-BCA 1|P age C++ OVERVIEW C++ is a statically typed, compiled, general-purpose, case-sensitive, free- form programming language that supports procedural, object-oriented, and generic programming. C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features. C++ was developed by BjarneStroustrup starting in 1979 at Bell Labs in Murray Hill, New Jersey, as an enhancement to the C language and originally named C with Classes but later it was renamed C++ in 1983. C++ is a superset of C, and that virtually any legal C program is a legal C++ program. 2|P age #include usingnamespacestd; int main() { cout Checks if the value of left operand (A > B) is not true. is greater than the value of right operand, if yes then condition becomes true. < Checks if the value of left operand (A < B) is true. is less than the value of right operand, if yes then condition becomes true. >= Checks if the value of left operand (A >= B) is not true. is greater than or equal to the value of right operand, if yes then 26 | P a g e condition becomes true. num2) result= num1; else result= num2; return result; } Function Declarations: A function declaration tells the compiler about a function name and how to call the function. The actual body of the function can be defined separately. A function declaration has the following parts: return_typefunction_name( parameter list ); For the above defined function max(), following is the function declaration: int max(int num1,int num2); Parameter names are not importan in function declaration only their type is required, so following is also valid declaration: int max(int,int); 40 | P a g e Function declaration is required when you define a function in one source file and you call that function in another file. In such case, you should declare the function at the top of the file calling the function. Calling a Function: While creating a C++ function, you give a definition of what the function has to do. To use a function, you will have to call or invoke that function. When a program calls a function, program control is transferred to the called function. A called function performs defined task and when its return statement is executed or when its function-ending closing brace is reached, it returns program control back to the main program. To call a function, you simply need to pass the required parameters along with function name, and if function returns a value, then you can store returned value. For example: #include usingnamespacestd; // function declaration int max(int num1,int num2); int main () { // local variable declaration: int a =100; int b =200; int ret; // calling a function to get max value. ret= max(a, b); cout