Last active
April 14, 2020 19:17
-
-
Save settermjd/b4bfdf5191afaaad5d5936916d47e447 to your computer and use it in GitHub Desktop.
Examples of the same class in multiple c-based languages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorld { | |
private String name; | |
public HelloWorld(String name) { | |
this.name = name; | |
} | |
public void printName() { | |
System.out.println(this.name); | |
} | |
public static void main(String[] args) { | |
HelloWorld obj = new HelloWorld("Matthew Setter"); | |
obj.printName(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class HelloWorld | |
{ | |
private $name = ''; | |
public function __construct(string $name) { | |
$this->name = $name; | |
} | |
public function printName() { | |
print $this->name; | |
} | |
} | |
$obj = new HelloWorld('Matthew Setter'); | |
echo $obj->printName(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorld: | |
name = "" | |
def __init__(self, name): | |
self.name = name | |
def printName(self): | |
print(self.name) | |
# Instantiate and call the printName method | |
obj = HelloWorld("Matthew Setter") | |
obj.printName() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment