GeekInterview.com
Series: Subject: Topic:
Question: 13 of 85

C++ Single Program

Write a program in C++ using encapsulation, inheritance, polymorphism and abstraction all the concepts should come in a single program.
Asked by: chamma | Member Since Jul-2010 | Asked on: Nov 13th, 2010

View all questions by chamma

Showing Answers 1 - 1 of 1 Answers
nikki

Answered On : 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. }

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.