CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2019
    Posts
    1

    What is the difference between procedural and object-oriented programs? Write simple

    What is the difference between procedural and object-oriented programs? Write simple

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: What is the difference between procedural and object-oriented programs? Write sim

    Do an Internet search. There are many articles available.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    Join Date
    Feb 2017
    Posts
    677

    Re: What is the difference between procedural and object-oriented programs? Write sim

    Quote Originally Posted by rajeshkumarr4r View Post
    What is the difference between procedural and object-oriented programs?
    Procedural languages have a fixed number of data types such as for example int, float, char and string, and there is a fixed number of operations on each data type such as for example addition and multiplication.

    Most object oriented languages have a procedural base but in addition offer the so called class concept. It allows programmers to introduce own new data types and define own operations on them.

    So procedural programming is about juggling a limited number of existing data types whereas OO programming is about introducing new data types by way of classes. There's more to it but that's the difference in a nutshell.
    Last edited by wolle; April 3rd, 2019 at 02:21 AM.

  4. #4
    Join Date
    Apr 2019
    Location
    Ahmedabad
    Posts
    7

    Re: What is the difference between procedural and object-oriented programs? Write sim

    Procedural Programming is the version of structured programming that uses functions (subroutines) to take input values and return (usually) changed values to the calling routine. It is the standard programming paradigm.

    Object oriented programming believes in encapsulating behavior and values in objects, which can be seen as analogs for the tasks that the program would look to accomplish. An objects will exist in memory by virtue of being instantiated before its methods are invoked. An object will be an instance of a class, which will have data and methods, which one of the things that differentiates an OO class from a procedural function: i.e. a class can have many methods exposed via the object where a function or subroutine is going to have a single interface.

  5. #5
    Join Date
    Mar 2019
    Location
    USA
    Posts
    4

    Re: What is the difference between procedural and object-oriented programs? Write sim

    Procedural Object-oriented

    procedure method
    record object
    module class
    procedure call message

  6. #6
    Join Date
    Feb 2017
    Posts
    677

    Re: What is the difference between procedural and object-oriented programs? Write sim

    I'd like to clarify my post #3.

    The key difference is the class concept available in OO languages. It allows programmers and library providers to define new types. To see how this works, let's have a look at the initialization statement available in every language. Formally it's usually defined something like this,

    <type> <variable> = <value>;

    In both procedural and OO languages it can look like this where int (a primitive) is defined by the language,

    int n = 5;

    In an OO language one can also find this where Int (a class) is not defined by the language but by someone else,

    Int n = new Int(5);

    Comparing these it's easy to see that,

    - the primitive int and the class Int are both <types>,
    - n is the <variable> in both cases, and
    - the literal 5 and the object returned by new Int(5) are both <values>.

    This illustrates how the OO concept is seamlessly integrated with a procedural base. All the fundamentals of a procedural language are there. The only difference is that thanks to the class concept an OO language allows new types to be defined by way of classes. In short:

    OO language = procedural language + classes.

    So the key player is the type. It defines all operations that can be performed on the values of the type. For example the int type most likely defines a plus operation and so does the Int type. It follows that the methods of a class are not procedures in the procedural sense. They are definitions of operations on the objects of a class. But procedures are still available in OO languages. In Java for example a method can be turned into a procedure by declaring it static. Check out the Math class for example. Furthermore, an object is a value and not a record in the procedural sense. But records can easily be mimicked in OO by defining classes with publicly exposed variables only and no methods. Note that the terminology of OO is applicable also on procedural primitive types such as int, float and char. These can be viewed as classes with objects and operations, only they constitute a fixed part of the language.

    In summary, the only difference between procedural and OO languages is the class concept which allows new types to be defined. This fosters a programming style with focus on how to create and combine types, rather than how to organize procedures. As I said in #3, there's more to it but that's the difference in a nutshell.
    Last edited by wolle; April 16th, 2019 at 11:00 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured