• Streams & Subjects

    Streams & Subjects

    Get detailed description of each and every topic with proper examples including text, images and videos.

  • Latest Technologies

    Latest Technologies

    Know more about the latest and new emerging technologies and boost your knowledge.

  • Programming

    Programming

    Don't learn just codes and syntax, instead learn the best and efficient way of coding.

  • Technologies

    New Technologies

    Get instant and relevant updates of the latest emerging technologies of lots of streams including web, clouds, virtualization, etc.

  • Freewares

    Freewares

    Download free trials and freewares of various fields and check out their efficiency before buying.

  • Multimedia

    Multimedia

    Learn techniques to design amazing and creative multimedia designs and characters including 2D & 3D layout with rendering.

Showing posts with label OOPS Programs. Show all posts
Showing posts with label OOPS Programs. Show all posts

Program to demonstrate Class and Object



//Program to demonstrate Class and Object in C++

#include <iostream.h>
#include <conio.h>
class Box
{
            public:
                        double length;   // Length of a box
                        double breadth;  // Breadth of a box
                        double height;   // Height of a box
};
int main( )
{
            clrscr();
            Box Box1;        // Declare Box1 of type Box
            double volume;     // Store the volume of a box here
           
            // box1 specification
            Box1.height = 5.0;
            Box1.length = 6.0;
            Box1.breadth = 7.0;

            // volume of box 1
            volume = Box1.height * Box1.length * Box1.breadth;
            cout << "Volume of Box1 : " << volume <<endl;
            getch();
            return 0;
}


Read more