StudyLover
  • Home
  • Study Zone
  • Profiles
  • Contact us
  • Sign in
StudyLover 18. Program to allocate memory dynamically for an object of a given class using the class’s constructor.
Download
  1. C++ Programs list
17. Program to demonstrate inheritance and polymorphism using virtual functions. : 19. Program to read the data of `n` employees and compute the net salary of each employee (DA = 52% of basic and IT = 30% of the gross salary).
C++ Programs list

1.      Program to allocate memory dynamically for an object of a given class using the class’s constructor.

  1. #include <iostream.h>

  2. #include<conio.h>

  3. class MyClass {

  4. public:

  5.     int data;

  6.  

  7.     MyClass(int d) {

  8.         data = d;

  9.     }

  10.  

  11.     void display() {

  12.         cout << "Data: " << data << endl;

  13.     }

  14. };

  15.  

  16. int main() {

  17.     MyClass *obj = new MyClass(10);

  18.  

  19.     obj->display();

  20.  

  21.     delete obj;

  22.     getch();

  23.     return 0;

  24. }

  25.  

17. Program to demonstrate inheritance and polymorphism using virtual functions. 19. Program to read the data of `n` employees and compute the net salary of each employee (DA = 52% of basic and IT = 30% of the gross salary).
Our Products & Services
  • Home
Connect with us
  • Contact us
  • +91 82955 87844
  • Rk6yadav@gmail.com

StudyLover - About us

The Best knowledge for Best people.

Copyright © StudyLover
Powered by Odoo - Create a free website