Home TechnologyProgramming Subscribe to RSS

Can You Define Classes Concept In Object-Oriented Programming?

Classes concept in OOP.

Answer Question

3 Answers - Sort by: Date | Rating

    In OOP objects are the members of classes. What does this mean? Let's look at an analogy. Almost all computer languages have built-in data types. For instance, a data type int, meaning integer, is predefined in C++. You can declare as many variables of type int as you need in your program:
    Int day;
    Int count;
    Int divisor;
    Int answer;
    In a similar way, you can define many objects of the same class. A class serves as a plan, or template. It specifies what data and what functions will be included in objects of that class. Defining the class doesn't create any objects, just as the mere existence of data type int doesn't create any variables.
    A class is thus a description of a number of similar objects. This fits our non-technical understanding of the word class. Prince, sting, and Madonna are members of the class of rock musicians. There is no one person called "rock musician," but specific people with specific names are members of this class if they possess certain characteristics.
    0 0

    Rauf786 

    answered 3 years ago

      Re usability in Object-Oriented Programming has a key importance, once a class has been written, created, and debugged, it can be distributed to other programmers for use in their own programs. This is called re usability. It is similar to the way a library of functions in a procedural language can be incorporated into different programs.

      However, in OOP, the concept of inheritance provides an important extension to the idea of reusability. A programmer can take an existing class and, without modifying it, add additional features and capabilities to it. This is done by a deriving a new class from the existing one. The new class will inherit the capabilities of the old one, but is free to add new features of its own.

      For example, you might have written (or purchased from someone else) a class that creates a menu system, such as that used in Windows or other Graphic User Interfaces (GUIs). This class works fine, and you don't want to change it, but you want to add the capability to make some menu entries flash on and off. To do this, you simply create a new class that inherits all the capabilities of the existing one but adds flashing menu entries.
      0 0

      Rauf786 

      answered 3 years ago

        In OOP objects are the members of classes. What does this mean? Let's look at an analogy. Almost all computer languages have built-in data types. For instance, a data type int, meaning integer, is predefined in C++. You can declare as many variables of type int as you need in your program:
        Int day;
        Int count;
        Int divisor;
        Int answer;

        In a similar way, you can define many objects of the same class. A class serves as a plan, or template. It specifies what data and what functions will be included in objects of that class. Defining the class doesn't create any objects, just as the mere existence of data type internet doesn't create any variables.

        A class is thus a description of a number of similar objects. This fits our non-technical understanding of the word class. Prince, sting, and Madonna are members of the class of rock musicians. There is no one person called "rock musician," but specific people with specific names are members of this class if they possess certain characteristics.
        0 0

        Rauf786 

        answered 3 years ago

        More

           
           

          Ask a Question via Twitter

          Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

          Blurtit Store

          Get T-shirts, hoodies, caps and more at the Blurtit store

          Blurtit International