Write a program to implement single inheritance from the following Refer Figure No.1

electronics2electrical.com 696 -  .jpg

1 Answer

Answer :

#include<iostream.h>

#include<conio.h>

class employee

{

protected:

int emp_id;

char name[10];

};

class emp_info:public employee

{

int basic_salary;

public:

void getdata()

{

cout<<"Enter emp id";

cin>>emp_id;

cout<<"Enter name";

cin>>name;

cout<<"Enter basic salary";

cin>>basic_salary;

}

void putdata()

{

cout<<"\nEmp_id="<<emp_id;

cout<<"\nName="<<name;

cout<<"\nBasic Salary="<<basic_salary;

}

};

void main()

{

emp_info e;

clrscr();

e.getdata();

e.putdata();

getch();

}

Related questions

Description : Write a program to implement the following hierarchy using suitable member functions. Refer Figure No.2.

Last Answer : # include <iostream.h> #include<conio.h> class Student { int roll_no; char name[10]; public: void read_studentData() { cout<< Enter student s roll no and name \n ; cin> ... { result r; clrscr(); r.read_result(); r.display_result(); getch(); }

Description : Write a program in C++ to implement single inheritance from following figure:

Last Answer : #include<iostream.h> #include<conio.h> class product { protected: int prodid; char prodname[20]; }; class edible:public product { char flavour[20]; public: void accept() { cout<< ... for(i=0;i<5;i++) { e[i].display(); } getch(); }

Description : Write a program to implement multiple inheritance as shown in following Figure No.1: Accept and display data for one object of class result.  

Last Answer : Program: #include<iostream.h> #include<conio.h> class Subject1 { protected: float m1; }; class Subject2 { protected: float m2; }; class Result:public Subject1,public Subject2 { ... ; clrscr(); r.accept(); r.calculate(); r.display(); getch(); }

Description : Write a C++ program to implement inheritance shown in following figure: Accept and display data of one teacher and one student using object of class ‘Info’

Last Answer : #include<iostream.h> #include<conio.h> class Teacher { protected: char Name[20]; int empid; }; class Student { protected: char sname[20]; int rollno; }; class Info:public ... I.acceptT(); I.displayT(); I.acceptS(); I.displayS(); getch(); }

Description : Write a program to implement single inheritance. Declare base class employee with Emp_No. and Emp_Name. Declare derived class fitness with height and weight. Accept and display data for one employee.

Last Answer : #include<iostream.h> #include<conio.h> class employee { protected: int emp_no; char emp_name[10]; public: void gete() { cout<< enter employee details ; cin>>emp_no; cin>> ... f.gete(); f.pute(); f.getft(); f.putft(); getch(); }

Description : Write a C++ program to implement following inheritance. Accept and display data for one programmer and one manager. Make display function virtual.  

Last Answer : #include #include class Employee  { int empid,empcode; public: void emp() { coutempid; coutempcode; } void virtual display() { cout

Description : Write a program in C++ to implement following inheritance. Assume suitable data.

Last Answer : #include<iostream.h> #include<conio.h> class employee { int empid; char empname[20]; public: void accept() { cout<<"\n enter empid, empname:"<<endl; cin>>empid>> ... m.acc1(); m.dis1(); w.acc2(); w.dis2(); getch(); }

Description : What is inheritance? Give different types of inheritance.

Last Answer : Inheritance: The mechanism of deriving new class from an old/existing class is called inheritance. OR Inheritance is the process by which objects of one class acquired the properties of ... is a combination of single, multiple, multilevel and hierarchical inheritance. Diagram:

Description : What is multilevel inheritance? Draw the diagram to show multilevel inheritance. using classes with data member and member function. 

Last Answer : When a class is derived from another derived class then it is called as multilevel inheritance.

Description : Implement single inheritance for following fig. Accept and display data for 1 table.

Last Answer : #include class furniture { protected: char material[20]; int price; }; class table :public furniture { int height ; float sur_area; public: void getdata() { coutmaterial; coutprice; coutheight; coutsur_area; } void putdata() { cout

Description : Write a program to implement the concept of virtual base class for following figure. Accept and display information of one employee with his name, code, basic pay, experience and gross salary with the object of employee class.

Last Answer : #include<iostream.h> #include<conio.h> class Master  {  char name[10],code[3];  public:  void acceptM() { cout<<"\nEnter name and code "; cin>>name>>code; ... .displayM(); e.displayA(); e.displayD(); e.displayE(); getch();  }

Description : Write a program to declare a class ‘book’ containing data members as ‘title’, ‘author-name’, ‘publication’, ‘price’. Accept and display the information for one object using pointer to that object.

Last Answer : #include<iostream.h> #include<conio.h> class book { char author_name[20]; char title[20]; char publication[20]; float price; public: void Accept(); void Display(); }; void ... title \t author_name \t publication \t price\n ; p-> Display(); getch(); }

Description : Write a program that copies contents of one file into another file.

Last Answer : Assuming input file to be copied file1.txt contents are “Hello Friends…” and file where the contents need to copy is file2.txt already created  #include #include #include #include #include void main() { clrscr(); ifstream fs; ofstream ft; char ch, fname1[20], fname2[20]; cout

Description : Write a program to overload the ‘—’ unary operator to negate the values.

Last Answer : #include<iostream.h> #include<conio.h> #include<string.h> class Number { int x,y; public: Number (int a, int b) { a =x; b =y; } void display() { cout<< ... ; -N1; cout<<"\n After negation:"; N1. display (); getch (); }

Description : Write a program to count the number of lines in file.

Last Answer : #include<iostream.h> #include<fstream.h> #include<conio.h> void main() { ifstream file; char ch; int n=0; clrscr(); file.open("abc.txt"); while(file) { file. ... \n Number of lines in a file are:"<<n; file.close(); getch(); }

Description : Write a program to sort an 1-d array in ascending order.

Last Answer : #include<iostream.h> #include<conio.h> void main() { int arr[20]; int i, j, temp,n; clrscr(); cout<<"\n Enter the array size:"; cin>>n; cout<<"\n Enter ... 0;i<n;i++) {  cout<< \n <<arr[i]; } getch(); }

Description : Module design is used to maximize cohesion and minimize coupling. Which of the following is the key to implement this rule? (A) Inheritance (B) Polymorphism (C) Encapsulation (D) Abstraction

Last Answer : (C) Encapsulation

Description : Write the applications of object oriented programming.

Last Answer : Applications of object oriented programming are: 1) Real time systems 2) Simulation and modeling 3) Object-oriented databases 4) Hypertext, hypermedia and expertext 5) AI and expert systems ... and parallel programming 7) Decision support and office automation systems 8) CIM/CAM/CAD systems

Description : Write any four benefits of OOP. 

Last Answer : Benefits of OOP: 1. We can eliminate redundant code and extend the use of existing classes. 2. We can build programs from the standard working modules that communicate with one another, ... interface descriptions with external systems much simpler. 10. Software complexity can be easily managed.

Description : Write two properties of static member function

Last Answer : i) A static member function can have access to only other static data members and functions declared in the same class. ii) A static member function can be called using the class name with a scope resolution operator instead of object name as follows: class_name::function_name;

Description : Write a program which implement the concept of overloaded constructor.

Last Answer : #include #include class integer { int m,n; public: integer() { m=0; n=0; } //default constructor 1 integer(int a, int b) { m=a; n=b; } //Parameterized constructor 2 integer(integer &i) { m=i.m; n=i.n; } //copy constructor 3 }; void display() { cout

Description : Write a C++ program for following multilevel inheritance.   Accept and display data for one car with all details.   

Last Answer : #include<iostream.h> #include<conio.h> class Carmanufacturer  { char Name[10]; public: void getcarm() { cout<<"\nEnter Car Name "; cin>>Name; } void putcarm() ... getcar(); c.putcarm(); c.putcarmodel(); c.putcar(); getch();  }

Description : Write a program for multiple inheritance. 

Last Answer : #include #include class base1 { public: void show1() { cout

Description : Explain the friend function with proper example.

Last Answer : Friend function: The private members of a class cannot be accessed from outside the class but in some situations two classes may need access of each other s private data. So a common function can be declared which can be made friend ... ; } friend void swap(A,B); }; void swap(A a,B b) { cout

Description : What is parameterized constructor?

Last Answer : A constructor that accepts parameters is called as parameterized constructor. In some applications, it may be necessary to initialize the various data members of different objects with different values when they are ... an argument. Member function put ( ) displays the value of data member m .

Description : What are the rules for virtual function?

Last Answer : Rules for virtual function: 1. The virtual functions must be members of some class. 2. They cannot be static members. 3. They are accessed by using object pointers. 4. A virtual function can ... virtual function is defined in the base class, it need not be necessarily redefined in the derived class.

Description : State the rules for writing destructor function.

Last Answer : Rules for writing destructor function are: 1) A destructor is a special member function which should destroy the objects that have been created by constructor. 2) Name of destructor and name of the class should ... should not be classified in any types. 7) A class can have at most one destructor. 

Description : Describe ‘this’ pointer with an example.

Last Answer : this' pointer:  C++ uses a unique keyword called this to represent an object that invokes a member function. This unique pointer is automatically passed to a member function when it is invoked. ... pointer is used to represent object s when setdata ( ) and putdata ( ) functions are called. 

Description : Describe memory allocation for objects.

Last Answer : The memory space for object is allocated when they are declared and not when the class is specified. The member functions are created and placed in memory space only once when they are ... are essential because the member variables will hold different data values for different objects.

Description : Give syntax and use of fclose ( ) function.

Last Answer : Syntax:  int fclose(FILE* stream); Use: This function is used to close a file stream. The data that is buffered but not written is flushed to the OS and all unread buffered data is discarded.

Description : Explain virtual base class with suitable example.

Last Answer : Consider a situation where all three kinds of inheritance, namely, multilevel, multiple, hierarchical inheritance, are involved. This illustrated in fig a. the child has two direct base classes, parent1 & ... Grandparent { }; class Child: public Parent1,public Parent2 { };

Description : Explain use of scope resolution operator.

Last Answer : It is used to uncover a hidden variable. Scope resolution operator allows access to the global version of a variable. The scope resolution operator is used to refer variable of class anywhere in program. ... outside of class. Return_type class_name:: function_name( ) { Function body }

Description : What is a class? Give its example. 

Last Answer : Class is a user defined data type that combines data and functions together. It is a collection of objects of similar type. Example: class Student { int rollno; char name[10]; public: void getdata( ); void putdata( ); };

Description : State the difference between OOP and POP.

Last Answer : OBJECT ORIENTED PROGRAMMING (OOP) PROCEDURE ORIENTED PROGRAMMING (POP) Focus is on data rather than procedure. Focus is on doing things (procedure). Programs are divided into multiple ... approach is used in C++ language. Procedure oriented approach is used in C language.

Description : The new organization established to implement the Fifth Generation Project is called _____________ a) ICOT (Institute for New Generation Computer Technology) b) MITI (Ministry of International ... c) MCC (Microelectronics and Computer Technology Corporation) d) SCP (Strategic Computing Program)

Last Answer : a) ICOT (Institute for New Generation Computer Technology)

Description : Implement a program to demonstrate concept of pointers to function.

Last Answer : Pointer to function: include int sum(int x, int y) { return x+y; } int main() { int s; int(*fp)(int, int); fp = sum; s = fp(10,12); printf(“Sum = %d”,s); return 0; }

Description : Implement a program to demonstrate logical AND operator.

Last Answer : #include #include void main() { int i; int j; clrscr(); printf("Enter the values of i and j"); scanf("%d%d",&i,&j); if(i==5 && j==5) { printf("Both i and j are equal to 5"); } else { printf("Both the values are different and either or both are not equal to 5"); } getch(); }

Description : Implement a program to declare a class city with data members city name and state. Accept and display data for 1 object using pointer to object.

Last Answer : #include<iostream.h> #include<conio.h> class city { char city_name[20],state[20]; public: void accept() { cout<<"\nEnter city data:"; cout<<"\nName:"; ... ); ptr=&c; ptr->accept(); ptr->display(); getch(); }

Description : Refer to figure 3-55(A). If the following resistors were replaced with the values indicated: R1 = 900Ω, R3 = 1kΩ, what is the total power in the circuit? What is ER2?

Last Answer : PT = 60 W, ER2 = 10 V.

Description : Refer to figure 2-3(B). Why is the sulfuric acid decreasing?

Last Answer : The sulfuric acid is chemically acting upon the anode and cathode which creates a current flow through the load

Description : is pulled and guided from single hitch point but its weight is not supported by the tractor. A. Trailed type implement C. Semi mounted type implemented B. Mounted type implemented D. Automatic implemented

Last Answer : Trailed type implement

Description : An implement that pulled and guided by single hitch point of a tractor is: a) Trailed implement c) Mounted implement b) Semi mounted implements d) All are correct

Last Answer : Trailed implement

Description : Why is the concept of a single gene as the ultimate unit of inheritance inadequate to provide a unitary explanation for protein synthesis, recombination, and mutation?

Last Answer : The primary function of the gene is to code for a protein product. Sufficient DNA must be present to account for each of the amino acids making up the primary structure of the protein. It is ... . The recon, the unit involved in recombination, may be only slightly shorter than the full cistron. 

Description : .Match the terms in column I with their description in column II and choose the correct option. Column I Column II A. Dominance (i) Many genes govern a single character B. Co-dominance (ii) In a heterozygous organism only one allele ... (i) (ii) (c) (ii) (i) (iv) (iii) (d) (ii) (iii) (iv) (i)

Last Answer : (d) (ii) (iii) (iv) (i)

Description : Which type of Mendelian inherited condition results in both genders being affected equally in a vertical pattern? a) Automosomal dominant inheritance An individual who has an autosomal dominant ... that combine during early embryonic development leading to incomplete closure of the neural tube.

Last Answer : a) Automosomal dominant inheritance An individual who has an autosomal dominant inherited condition carries a gene mutation for that condition on one chromosome of a pair.

Description : Explain single inheritance with suitable example.

Last Answer : When a single derived class is derived from only one base class then it is called as single inheritance. In a single inheritance, derived class can inherit some or all members of base class. It is implemented by specifying ... s; clrscr(); s.getdata(); s.putdata(); getch(); }

Description : In a CNC program block, N05 GO1 G91 G33 X20 Z-40 K5……, K refer to a.Depth of cut b.Pitch c.Multiple Threading Cycle d.Feed

Last Answer : b.Pitch

Description : In CNC Program M98 is refer to…… a.CANCEL Subroutine b.Call Sub-Program c.Call Subroutine d.CANCEL Sub-Program

Last Answer : b.Call Sub-Program

Description : In CNC Program M03 is refer to…… a.Spindle ON in Clockwise rotation b.Spindle ON in Counter Clockwise rotation c.Spindle OFF in Clockwise rotation d.Spindle OFF in Counter Clockwise rotation

Last Answer : a.Spindle ON in Clockwise rotation

Description : In a CNC program block, N05 GO1 G91 G33 X20 Z-40……, G33 refer to a.Peck Drilling b.Counter Boring c.Thread Cutting d.Grooving

Last Answer : c.Thread Cutting