Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Virtual Functions
The keyword virtual was previously used to resolve ambiguity for a class derived from two classes, both having a common ancestor. These classes are known as virtual base classes. This time it helps in implementing the idea of polymorphism with class inheritance. The function of the base class can be declared with the keyword virtual. The program with this change and its output is given below.
class Shape
{
public :
virtual void print()
cout << " I am a Shape " << endl;
}
};
class Triangle : public Shape
void print()
cout << " I am a Triangle " << endl;
class Circle : public Shape
cout << " I am a Circle " << endl;
void main()
Shape S;
Triangle T;
Circle C;
S.print();
T.print();
C.print();
Shape *ptr;
ptr = &S;
ptr -> print();
ptr = &T;
ptr = &C;
B a s i c D a t a t y p e : T h e r e a r e t h r e e t y p e o f d a t a t y p e i n C+ + 1. P r
C program to add, average and deviation of numbers: void main() { int sum=0,a[10],i; float avg=0,dev,vari=0,var; pri
Addition of array elements: #define rows 3 #define cols 3 void main() { int i=0,j=0,sum=0; int arr[rows][cols];
HOW THE C PROGRAM CODING IMPLEMENTED DY ITSELF UNDERSTANDING . ALSO HOW I CAN A BECOME A GOOD PROGRAMMER IN C WHAT I DO FOR GOOD PROGRAMMING ,TELL ME HOW C CODING DEVELOP DY ITSELF
Program is to define a class as teacher: Program is to define a class as teacher and collect information about them by using classes and object class teacher { pr
drawbacks in assignments in engeenirng
C program to remove vowels in sentence : void main() { char str[100]; int n; printf("enter string\n");
Aim: To implement a program to convert distance given in feet and inches into meters and centimeters and vice versa. Code: class mcm; class
Integer literal Integer is numbers without fractional parts. e.g. 20 // Decimal 024 // Octal 0x14 // Hexadecimal To indicate long, unsigned,
Define a function in c program: int f1() { static int x=10; return x; } int f2() { int y=5; return y; } extern int z; void f() {
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +91-977-207-8620
Phone: +91-977-207-8620
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd