C++ Single Program

Write a program in C++ using encapsulation, inheritance, polymorphism and abstraction all the concepts should come in a single program.

Questions by chamma

Showing Answers 1 - 3 of 3 Answers

nikki

  • Aug 21st, 2011
 

I think all programs in C++ possess all features of object oriented.so we can implement a single & simpler program.

for eg:-

Code
  1. for eg:-

  2.  

  3. class Student{

  4.                        int rno;

  5.                    String name,add;

  6.     public void add(int r,String n){

  7.            rno=r;

  8.           name=n;          

  9.  

  10.              }

  11.      public void add(String a){

  12.  

  13.          add=a;

  14.         }

  15.  

  16. }

  17.  

  18.  abstract class college extends Student{

  19.                 int phone;

  20.           public void add(String n,String a,int rno,int p){

  21.                 super();

  22.        phone=p;

  23.  

  24. }

  25.      abstract public void view(){

  26.       cout<<"name="<<name;

  27.      cout<<"address="<<address;

  28.      cout<<"phone="<<phone;

  29.     cout<<"rno="<<rno;

  30.  

  31. }

  32.  void main(){

  33.         object obj();

  34.    obj.add("ram","mig",245689,101);

  35.    obj.view();

  36.        

  37.  

  38. }

  39.  

  40. }

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions