#include <iostream> using namespace std ; int sum ( int a , int b ){ cout << "by function1 is " ; return a + b; } int sum ( int a , int b , int c ){ cout << "by function2 is " ; return a + b + c; } int volume ( int a ){ return a * a * a; } int volume ( int r , int h ){ return 3.14 * r * r * h; } int volume ( int l , int b , int h ){ return l * b * h; } int main (){ cout << "the sum of 5 and 7 " << sum ( 5 , 7 ) << endl; cout << "the sum of 5, 7 and 57 " << sum ( 5 , 7 , 57 ) << endl; cout << "the volume of cube of side length 5 is " << volume ( 5 ) << endl; cout << "the volume of cylinder of radius 5 and height 7 is " << volume ( 5 , 7 ) << endl; cout << "the volume of cuboid of length 5, bredth 7...
/*OOPS---> Classes and Objects C++--> initially called as C with classes by stroustroup Class--> extension of structures in C Structures had limitations - members are public - a function cannot be created inside structure - no methods Classes --> Structures + more Classes --> can have methods and properties Classes --> can make few members as private and few as public Structues in c++ are typedef (mtlb typedef na lgakr bi structures ke varibales define kre to vo hojaenge) you can declare objects along with class declaration like this: class Employee { class definition } krishna, shalini; harry.salary = 9 makes no sense if salary is private */ /************NESTING OF MEMBER FUNCTIONS******** */ #include <iostream> using namespace std ; // int main(){ // binary b; // b.read(); // ...
/**************OBJECT ORIENTED PROGRAMMING (oops)************ */ /*why oops??? #c++ language was designed with the main intention of adding object oriented features to C language #as the size of program increases readability, maintaibility and bug free nature of the program decreases. #this was tha main problem with langage C #as a result the possiblity of not addressing the problem in an effective way increases #also, as data was almost neglected, data security was easily compromised #using classes solves this problem by modelling program as a real world scenario PROCEDURE ORIENTED PROGRAMMING (POP) (jo abi tak kr rahe the) #consists of writing a sequence of instructions for the computer to follow #main focus is one functions and not on the flow of data #functions can either use local or global data #data moves openly from function to function OBJECT ORIENTED PROGRAMMING #Works on the basis of CLASSES and OBJECTS #A class is a template to create objects #treats data as a critical elem...
Comments
Post a Comment