Join Our WhatsApp Group Join Subscribe Now!

OOP (313304) Practical No.16:Write programs to implement- Pointer to object

OOP (313304) Practical No.16:Write programs to implement- Pointer to object

OOP (313304) Practical No.16:Write programs to implement- Pointer to object

The pointer to objects helps to improve the efficiency of the program and access the objects dynamically. 

313304

A pointer is a variable that stores the memory address of another variable (or object) as its value. A pointer aims to point to a data type which may be int, character, double, etc.

Pointers to objects aim to make a pointer that can access the object, not the variables. Pointer to object in C++ refers to accessing an object.

OOP (313304) Practical No.16 Exercise:

1. State output of the following code:

#include <iostream.h>
#include<conio.h>
class myclass
{
int i;
public:
void read(int j)
{
i= j;
}
int getint()
{
return i;
}
};
void main()
{
clrscr();
rnyclass ob, *objectPointer;

objectPointer = &ob;
objectPointer->read(lO);
cout<<objectPointer->getint();
getch();

Answer:

OOP


2. Which is the pointer that denotes the object calling the member function?

Answer:  b) This pointer

3. A pointer can be initialized with

Answer: All of the above


Practical Related Questions

1 Write a C++ program to declare a class "Book" contammg data members book_name, auther_name, and price . Accept this information for one object of the class using pointer to that object.

Answer:


2 Write a C++ program to declare a class "Box" having data members height, width and breadth. Accept this information for one object using pointer to that object . Display the area and volume of that object.

Answer:


3. Write a C++ program to declare a class birthday having data members day, month, year. Accept this information for five objects using pointer to the array of objects

Answer:


4. Complete the following table:

Answer:


Conclusion

We successfully completed OOP (313304) Practical No.16 and Wrote C++ programs to implement- Pointer to object.

About the Author

Hi everyone, I'm Suraj Diware, and I'm passionate about helping students succeed in MSBTE programs. This blog is dedicated to providing clear and concise explanations of MSBTE curriculum topics, along with practical tips and resources to sup…

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.