Classes in Multiple Languages

You,misc

classes and objects in multiple languages

C#

/* Online C# Compiler and Editor */
using System.IO;
using System;
 
class ElectronicBoy
{
    private int id;
    private string name;
    public ElectronicBoy(int boyId, string boyName)
    {
        this.id = boyId;
        this.name = boyName;
    }
    
    public void showInfo()
    {
        Console.WriteLine("name: {0} ID: {1}",this.name,this.id);
    }
}
    
 
class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, World!");
        ElectronicBoy eb = new ElectronicBoy(99, "zombieMan");
        eb.showInfo();
    }
}

C++

/* Online C++ Compiler and Editor */
#include <iostream>
#include <string.h>

using namespace std;
class Student
{
    public: char name[100];
    public: int rollnr;
    
    public: Student(const char *  s, int i)
            {
            strcpy(name,s);
            rollnr =i;
            }
            
    public: void showInfo()
        {
        printf("Student: %s , rollnr : %d", name, rollnr);
        }
};

int main()
{
   Student s = Student ("jojo", 42);
   s.showInfo();
   return 0;
}

Javascript

/* Simple Hello World in Node.js */
console.log("Hello World");

var a = {name: "jojoboy",id:42};

console.log(a);

Dart

/* Simple Hello, World! program */
class hello
{
    public   printInfo()
    {
        print("Info: xxxxx");
    }
}
 
void main(){
   print("Hello, World!");
   var c = new hello();
   c.printInfo();
}

Recap - object instantiation in various languages

C#

ElectronicBoy eb = new ElectronicBoy(99, "zombieMan"); 

C++

Student s = Student ("jojo", 42);

javascript

var a = {name: "jojoboy",id:42};

Dart

var c = new hello();