Posts

C++ Program For Banking System Using Class | C++ Programming

C++ Program For Banking System Using Class #include <iostream> using namespace std ; #include <iomanip> class bank {     char name [ 20 ];     int acno ;     char actype [ 20 ];     int bal ; public:     void opbal ( void );     void deposit ( void );     void withdraw ( void );     void display ( void ); }; void bank :: opbal ( void ) {     cout << endl          << endl;     cout << "Enter Name :-" ;     cin >> name ;     cout << "Enter A/c no. :-" ;     cin >> acno ;     cout << "Enter A/c Type :-" ;     cin >> actype ;     cout << "Enter Opening Balance:-" ;     cin >> bal ; } void bank :: deposit ( void ) {     cout << "Enter Deposit amount :-" ;     int deposit = 0 ;     cin >> deposit ;     cout << " \n Deposit Balance = " << bal + deposit ; } void bank :: withdraw ( void ) {     int withdraw ;     c

C++ Program for Constructor Overloading | C++ Programming

Constructor Overloading When more than one constructor function is defined in a class, then it is called constructor overloading or the use of multiple  constructors  in a class. It is used to increase the flexibility of a class by having a greater number of constructors for a single class. Overloading constructors in C++ programming gives us more than one way to initialize objects in a class.

C++ Program To Find Negation Of A Number | C++ Programming

C++ Program To Find Negation Of A Number #include <iostream> using namespace std ; class point {     int x , y ; public:     void getdata ()     {         cout << "Enter x and y coordinate:" ;         cin >> x >> y ;     }     void display ()     {         cout << "(" << x << "," << y << ")" ;     }     point operator- ()     {         point t ;         t . x = - x ;         t . y = - y ;         return t ;     } }; int main () {     point p , q ;     p . getdata ();     q = - p ;     cout << "q=" ;     q . display (); } OUTPUT Enter x and y coordinate: 5 4 q=(-5,-4)

Access Modifiers in C++

Access Modifiers in C++ Access modifiers are constructs that define the scope and visibility of members of a class. There are three access modifiers:

Types of Inheritance in C++ | C++ Programming

Types of Inheritance A class can inherit properties from one or more classes and from one or more levels. On the basis of this concept, there are five types of inheritance. Single Inheritance Multiple Inheritance Hierarchical Inheritance Multilevel Inheritance Hybrid Inheritance Single Inheritance In single inheritance, a class is derived from only one base class. The example and figure below show this inheritance. Example class A {  members of A }; class B  :  public A {  members of B }; Multiple Inheritance In this inheritance, a class is derived from more than one base class. The example and figure below show this inheritance. Implementation Skeleton: class A { members of A }; class B {  members of B }; class C  : public A, public B  { members of C }; Hierarchical Inheritance In this type, two or more classes inherit the properties of one base class. The example and figure below show this inheritance. Implementation Skeleton: class A { member

C++ Program To Find Factorial Of Two Numbers Using Recursion Function | C++ Programming

C++ Program To Find Factorial Of Two Numbers Using Recursion Function #include<iostream> using namespace std; long int fact(int); int main() { int n1,n2; cout<<"Enter number"< cin>>n1>>n2; cout<<n1<<"! = "<<fact(n1)<<endl; cout<<n2<<"! = "<<fact(n2)<<endl; } long int fact(int n) { if(n<=1) return 1; else   return (n*fact(n-1)); } OUTPUT Enter number 5 4 5! = 120 4! = 24

Type Conversion In C++

Type Conversion The type conversions are automatic as long as the data types involved are built-in types. If the data types are user-defined, the compiler does not support automatic type conversion and therefore, we must design the conversion routines by ourselves. Three types of situations might arise in the data conversion in this case. 1. Conversion from basic type to class type 2. Conversion from class type to basic type 3. Conversion from one class type to another class type