Object based programming in C++

  • Context: C/C++ 
  • Thread starter Thread starter kartikwat
  • Start date Start date
  • Tags Tags
    C++ Programming
Click For Summary

Discussion Overview

The discussion revolves around the concept of object-based programming, particularly in the context of C++. Participants explore its definition, how it localizes implementation details, and its distinction from object-oriented programming. The conversation includes inquiries about specific language features and references to educational materials.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification
  • Debate/contested
  • Homework-related

Main Points Raised

  • Some participants define object-based programming as using object-oriented principles in languages that lack direct support for objects, requiring manual implementation of encapsulation, inheritance, and polymorphism.
  • There is a suggestion that the understanding of object-based programming can vary significantly depending on the programming language in question.
  • One participant expresses confusion about specific terms from a textbook, asking for clarification on concepts like "information hiding" and "localizing implementation details."
  • A later reply explains the concept of separating implementation details using the example of the sin() function, emphasizing the distinction between interface and implementation.
  • Some participants request quotations from the referenced textbook to better address the original poster's confusion.
  • There is a mention of the potential disconnect between the educational background of participants, particularly regarding familiarity with specific textbooks used in different regions.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the definition and implications of object-based programming, with multiple competing views and ongoing questions about specific concepts and terminology.

Contextual Notes

Participants note that the understanding of object-based programming is influenced by the specific programming language being discussed, and that the original poster's textbook may not be widely known among contributors.

Who May Find This Useful

This discussion may be useful for students learning about programming concepts, particularly those studying object-based programming in C++ or similar languages, as well as educators seeking to clarify these concepts for their students.

kartikwat
Messages
49
Reaction score
0
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.
 
Technology news on Phys.org
kartikwat said:
What does object based programming mean?

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.


kartikwat said:
how does it localises the implementation details ,i tried to read it from book but i dint got it.

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?
 
Filip Larsen said:
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?

I refer to sumita arora class 12 book.do you have any suggestion
 
kartikwat said:
I refer to sumita arora class 12 book.

Most people who answer questions on PF are not from India, so we have no idea what is in that book.
 
kartikwat said:
I refer to sumita arora class 12 book.

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:
Filip Larsen said:
In short, object-based programming is when you are being object-oriented in a language that not necessarily has no direct support of objects ...

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?

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).
 
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.
 
  • #10
Object based programming

Are there any tutorial on computer science which can guide ne on my class 12 computer science course
 
  • #11
Hey this is explanation of object based programming .i can't get what it means.
 

Attachments

  • kartikwat1.jpg
    kartikwat1.jpg
    41 KB · Views: 474
  • kartikwat2.jpg
    kartikwat2.jpg
    45.5 KB · Views: 459
Last edited by a moderator:
  • #12
AlephZero said:
The thread title says "Object based programming in C++".

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 :-p
 
  • #13
kartikwat said:
i can't get what it means.

Start at the top of the first page. Tell us where you first get "stuck."
 
  • #14
Object based programming

jtbell said:
Start at the top of the first page. Tell us where you first get "stuck."

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.
 
  • #15
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:

Similar threads

Replies
86
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
81
Views
8K
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
693
Replies
69
Views
11K
Replies
65
Views
5K
  • · Replies 25 ·
Replies
25
Views
1K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 102 ·
4
Replies
102
Views
4K