0

Hi! "OBJECT is an instance of a class" then where is the object in the following code please........

class A 
{
 int a;
 int b;

 public:
 
 void display()
{

 cout<<"where is the object?";

};

Edited by ~s.o.s~: Fixed code tags

5
Contributors
8
Replies
10
Views
5 Years
Discussion Span
Last Post by tomtetlaw
0

This is the java forum not c++

But anyway it's OOP...please try answer the question

0

But anyway it's OOP

that's a myth...

C++ is NOT an object-oriented programming language it is a language with direct, native support for multiple programming paradigms

0

that's a myth...

C++ is NOT an object-oriented programming language it is a language with direct, native support for multiple programming paradigms

Then okay. But we use objects in c++ and some standard books quote it as OO language.I mean to say can't we find OBJECTS in the class definition?That I have threaded..?

0

To still answer your question. Above code does not create an object of the given class. You can consider class as a template as to what your object will look like. Using this class you can create an object in some other function (where you wish to use it) . And the function where you create the object will then invoke display() method on that object.

Edited by DJSAN10: n/a

0

Hi, i can say that: the objects are in the heaven! :D
'cause you had just described your class, you didn't declare any object!
Anyway, if you add this code:

A myA = new A();

then myA will be stored in memory, be processed ...and when you exit your program, myA will disappear!

0

myA won't disapear because it is allocated on the heap. you have to do delete myA; before your program exits then it will 'go away'

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.