Example Program Simple Class Example Program In C++


SUBMITTED BY: Nrupeshsinh

DATE: June 24, 2016, 8:30 a.m.

FORMAT: Text only

SIZE: 545 Bytes

HITS: 860

  1. #include <iostream>
  2. #include<conio.h>
  3. using namespace std;
  4. // Class Declaration
  5. class person
  6. {
  7. //Access - Specifier
  8. public:
  9. //Varibale Declaration
  10. string name;
  11. int number;
  12. };
  13. //Main Function
  14. int main()
  15. {
  16. // Object Creation For Class
  17. person obj;
  18. //Get Input Values For Object Varibales
  19. cout<<"Enter the Name :";
  20. cin>>obj.name;
  21. cout<<"Enter the Number :";
  22. cin>>obj.number;
  23. //Show the Output
  24. cout << obj.name << ": " << obj.number << endl;
  25. getch();
  26. return 0;
  27. }

comments powered by Disqus