Jump to content

is "Object" in "OOP" the same 'object' which is closely related to class and structur

- - - - -

  • Please log in to reply
8 replies to this topic

#1
jackson6612

jackson6612

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
Hi :)

I remember there is a particular kind of thing in C++ called 'object' which is part of the family whose members are also structure and class. But I think the "Object" in the title "Object-Oriented Programming" isn't the same 'object' which is much closely related to structure and class. Rather the "Object" only implies the concept where different sections of the software are seen as different entities or objects. Perhaps, other more descriptive and suitable term would ve 'functional blocks'. What is your opinion on this? Please let me know. Thanks.
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
In general programming an object normally refers to anything that can be modified, such as a variable or structure. In object oriented programming however it usually refers simply to the instance of a class, where the instance object has methods of its own and can freely interact with other portions of the program.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
jackson6612

jackson6612

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
Thank you, Alexander.

So, in plain words the "Object" in "OOP" refers to a self-sufficient distinct portion of a program. Please correct me if I'm wrong. Thanks.

Regards
Jackson
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
You can think of it as a generic term to describe data structures, of which can contain their own methods, data, or state. Languages of which implement objects often allow relationships between them, such as inheritance and polymorphism to name a few.

Alexander.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
jackson6612

jackson6612

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
Once again, thanks.

OOP is not a language rather it's a kind of functionality to organize the code effectively and efficiently. In C++ structure is also one way to organize things, then I believe comes class which is probably a more efficient than structure, and perhaps then comes object which is probably yet more efficient than class. Assuming what I said is correct, isn't there a yet more efficient way for organization than object? Please help me with it. Thank you.

Please note that I haven't read classes and object, and besides whatever C++ I knew some months ago is very rusty until now.
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)

#6
AKMafia001

AKMafia001

    Programmer

  • Members
  • PipPipPipPip
  • 119 posts
Discussing Classes and their objects we can take an example of blue prints. Imagine we have a blue print of a car that engineer have designed which contains all the functionalities of the car which is designed but can we drive the blue prints? Ofcourse not. We have to create a car using that blue prints and then we can drive it. Same as with the house blue prints. We can't sleep in blue print room or something else unless it is occured in reality. Same is the case here with Classes and objects. Classes are the blue prints and objects are their occurences. Simply object is the instance of the class. You may find the answer to your above post also.

Hope this helps!
I think i'm able to write a code for printing "Hello, World!". Proud of that!

#7
jackson6612

jackson6612

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts

AKMafia001 said:

Discussing Classes and their objects we can take an example of blue prints. Imagine we have a blue print of a car that engineer have designed which contains all the functionalities of the car which is designed but can we drive the blue prints? Ofcourse not. We have to create a car using that blue prints and then we can drive it. Same as with the house blue prints. We can't sleep in blue print room or something else unless it is occured in reality. Same is the case here with Classes and objects. Classes are the blue prints and objects are their occurrences. Simply object is the instance of the class. You may find the answer to your above post also.

Hope this helps!

Thank you, AK. Your post was really helpful.

I'm little confused about the two bold terms above. Do you mean that class is a blueprint and object is 'realization' of that blueprint (at least in virtual world)? What do you mean by "instance"? Please let me know. Thanks.

Regards
Jackson
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)

#8
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
Yes, a class is just code (i.e. class { ...}) an object is the actual instantiation of the class, i.e. object foo, bar, baz where those three objects are separate from each other, yet are the same class.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#9
jackson6612

jackson6612

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
Thank you for clearing the confusion, Alexander.

Best wishes
Jackson
I'm an outright beginner, learning C++. Using Win XP Pro and Code::Blocks. Be nice to me, please.:)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users