Posts

Showing posts from July 1, 2018

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