Write a C++ program using a concept of constructor.


SUBMITTED BY: Nrupeshsinh

DATE: July 4, 2016, 1:50 p.m.

FORMAT: Text only

SIZE: 285 Bytes

HITS: 285

  1. # include<iostream.h>
  2. # include<conio.h>
  3. class myclass
  4. {
  5. public:
  6. myclass()
  7. {
  8. int x;
  9. cout<<"Enter value :";
  10. cin>>x;
  11. cout<<"X="<<x;
  12. }
  13. };
  14. void main()
  15. {
  16. clrscr();
  17. myclass obj; //object is created and autometically called.
  18. getch();
  19. }

comments powered by Disqus