usingSystem;classAnimal{publicvirtualvoidsound(){Console.WriteLine("animal makes a sound");}}classDog:Animal{publicoverridevoidsound(){Console.WriteLine("dog barks");}}classCat:Animal{publicoverridevoidsound(){Console.WriteLine("cat meow");}}classTest{publicstaticvoidMain(){Animalan=newAnimal();Animald=newDog();Animalc=newCat();an.sound();d.sound();c.sound();}}
using System;
class web {
string name = "GeeksForGeeks";
public virtual void showdata()
{
Console.WriteLine("Website Name: " + name);
}
}
class stream : web {
string s = "Computer Science";
public override void showdata()
{
base.showdata();
Console.WriteLine("About: " + s);
}
}
class GFG {
static void Main()
{
stream E = new stream();
E.showdata();
}
}
using System;
class web {
string name = "GeeksForGeeks";
public virtual void showdata()
{
Console.WriteLine("Website Name: " + name);
}
}
class stream : web {
string s = "Computer Science";
public override void showdata()
{
base.showdata();
Console.WriteLine("About: " + s);
}
}
class GFG {
static void Main()
{
stream E = new stream();
E.showdata();
}
}
class web {
String name = "GeeksGorGeeks";
public void showdata(){
System.out.println("Website Name: " + name);
}
}
class stream extends web {
String s = "Computer Science";
@Override
public void showdata(){
super.showdata();
System.out.println("About: " + s);
}
}
public class GFG {
public static void main(String[] args) {
stream E = new stream();
E.showdata();
}
}
#include <stdio.h>
#include <string.h>
struct web {
char name[50];
void (*showdata)(struct web *);
};
void show_web_data(struct web *w) {
printf("Website Name: %s\n", w->name);
}
struct stream {
struct web base;
char s[50];
};
void show_stream_data(struct web *w) {
struct stream *s = (struct stream *)w;
show_web_data(w);
printf("About: %s\n", s->s);
}
// Initialize the web structure
void init_web(struct web *w) {
strcpy(w->name, "GeeksForGeeks");
w->showdata = show_web_data;
}
void init_stream(struct stream *s) {
init_web(&s->base);
strcpy(s->s, "Computer Science");
s->base.showdata = show_stream_data;
}
int main() {
struct stream E;
init_stream(&E);
E.base.showdata((struct web *)&E);
}
class web:
def __init__(self):
self.name = "GeeksForGeeks"
def showdata(self):
print("Website Name: " + self.name)
class stream(web):
def __init__(self):
super().__init__()
self.s = "Computer Science"
def showdata(self):
super().showdata()
print("About: " + self.s)
if __name__ == "__main__":
E = stream()
E.showdata()
#include <iostream>
#include <string>
using namespace std;
class web {
public:
string name;
public:
web() {
name = "GeeksForGeeks";
}
virtual void showdata() {
cout << "Website Name: " << name << endl;
}
};
class stream : public web {
public:
string s;
public:
stream() {
s = "Computer Science";
}
void showdata() override {
web::showdata();
cout << "About: " << s << endl;
}
};
int main() {
stream E;
E.showdata();
}