Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Object based programming in C++

  1. Jul 28, 2014 #1
    What does object based programming mean?how does it localises the implementation details ,i tried to read it from book but i dint got it.
     
  2. jcsd
  3. Jul 28, 2014 #2

    adjacent

    User Avatar
    Gold Member

  4. Jul 28, 2014 #3
  5. Jul 28, 2014 #4

    Filip Larsen

    User Avatar
    Gold Member

    In short, object-based programming is when you are being object-oriented in a language that not necessarily has no direct support of objects, i.e. mechanisms like encapsulation, inheritance, polymorphism and so on. In those languages you have to manually program these mechanisms in if you want them and the language has no native support for it. For instance, in Javascript you can use function instances to act as objects, and in C you can use structs and function pointers. Depending on the language it may not be an easy thing to do.


    It strongly depends on the language in question, so your question can only be answered in very general terms. Do you have a specific language in mind? And which book are you referring to?
     
  6. Jul 28, 2014 #5
    I refer to sumita arora class 12 book.do you have any suggestion
     
  7. Jul 28, 2014 #6

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    Most people who answer questions on PF are not from India, so we have no idea what is in that book.
     
  8. Jul 28, 2014 #7

    jtbell

    User Avatar

    Staff: Mentor

    Can you give us a short quotation from the book and tell us what, specifically, you don't understand about it?

    (Assuming the book is in English.)
     
    Last edited: Jul 29, 2014
  9. Jul 28, 2014 #8

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    The thread title says "Object based programming in C++".

    It would be strange to re-invent a different way of doing object based programming in C++ that did not use the object oriented features that are already in the language - certainly at high-school level ( which is what I guess the OP's "class 12" refers to).
     
  10. Jul 28, 2014 #9
    This seemed like a very good explanation to me.

    http://www.stroustrup.com/whatis.pdf

    That has been revised from what he published in IEEE Software a few years earlier. The earlier version ended each section with a list of problems that that style of programming did not handle well and was thus the reason for the invention of the next newer style. The article finally ended with a list of problems that object oriented programming did not handle well and which he said someone would find a solution to within the next decade. I always wondered if that advance was found and what it turned out to be.
     
  11. Jul 29, 2014 #10
    Object based programming

    Are there any tutorial on computer science which can guide ne on my class 12 computer science course
     
  12. Jul 29, 2014 #11
    Hey this is explaination of object based programming .i cant get what it means.
     

    Attached Files:

    Last edited by a moderator: Jul 29, 2014
  13. Jul 29, 2014 #12

    Filip Larsen

    User Avatar
    Gold Member

    It certainly does and I somehow managed to miss that completely. :redface: I hereby retract my question about which language the OP is thinking of :tongue:
     
  14. Jul 29, 2014 #13

    jtbell

    User Avatar

    Staff: Mentor

    Start at the top of the first page. Tell us where you first get "stuck."
     
  15. Jul 29, 2014 #14
    Object based programming

    In the first page I was not able to understand
    1) "classes enforce inforce information hiding and abstraction and there by seperating implementation details"
    2)in the point"OBP localises implementation details"I didnt got
    a)which definition type is changed
    b)what is user interface
    c)as a whole what does point mean.
     
  16. Jul 29, 2014 #15

    jtbell

    User Avatar

    Staff: Mentor

    To see what "separating implementation details" is all about, first consider a simple function: the sin() function which is available to you when you '#include <cmath>'. In order to use sin() properly, you need to know two things:

    1. You need to know its interface: you need to give it a number as its parameter, and it returns a number as the function result. This is often specified by the function's prototype:

    double sin (double x);

    'double sin' indicates that it returns a double-precision floating point number as its result, and 'double x' indicates that it receives a double-precision floating point number as its parameter. Actually, it's more complicated in this case, because sin() can deal with single-precision floating point ('float'), double-precision floating point ('double'), and I think also complex ('complex') numbers. But this simplified version at least gives you the idea of what the prototype specifies.

    2. You need to know what the function "does", its specification, which is usually given by a verbal description. For sin() it might be something like "returns the sine of the angle given by the parameter, which must be in radians."

    You do not need to know how the function calculates the sine: a series expansion of some kind, or by looking it up in a table, or whatever. This is an "implementation detail" which is "separated" from the knowledge of how to use the function.

    A class contains both (member) functions and (member) data. The member functions are like ordinary functions as far as "separating implementation details" is concerned.

    "Data abstraction" basically separates the details of the data contained in the class, from the things that you "do" with the class. Think of it as applying "separation of implementation details" to the class's member data. In practice this means that if your program uses the class, you can't use the class's member data directly; only indirectly by way of the member functions. This is "information hiding." The member data is "hidden" from "direct view" from the rest of your program.
     
    Last edited: Jul 29, 2014
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Object based programming in C++
  1. C program (Replies: 0)

  2. C programming (Replies: 9)

Loading...