Class

24px-Disambig_grey.svg.png 다른 뜻에 대해서는 클래스 문서를 참조하십시오.
24px-Disambig_grey.svg.png 다른 뜻에 대해서는 typeof 문서를 참조하십시오.

1 JavaScript[편집]

16px-Crystal_Clear_app_xmag.svg.png JavaScript 클래스 문서를 참고하십시오.
function Dog(name) {
  this.name = name;
  this.bark = function() {
    console.log("Woof! I'm " + this.name +".");
  }
}
var myDog = new Dog("Snoopy");
myDog.bark();
// Woof! I'm Snoopy.
var Dog = function(name) {
  this.name = name;
  this.bark = function() {
    console.log("Woof! I'm " + this.name +".");
  }
}
var myDog = new Dog("Snoopy");
myDog.bark();
// Woof! I'm Snoopy.
var Dog = function(name) {
  this.name = name;
}
Dog.prototype.bark = function() {
  console.log("Woof! I'm " + this.name +".");
}
var myDog = new Dog("Snoopy");
myDog.bark();
// Woof! I'm Snoopy.
var Dog = function(name) {
  var name;
  var Dog = {
    name: name,
    bark: function() {
    	console.log("Woof! I'm " + this.name +".");
    }
  }
	return Dog;
}
var myDog = new Dog("Snoopy");
myDog.bark();
// Woof! I'm Snoopy.

2 PHP[편집]

class Dog {
  public $name;
  public function __construct($name) {
    $this->name = $name;
  }
  public function bark() {
    echo "Woof!";
  }
}
$myDog = new Dog("snoopy");
$myDog->bark();

3 Python[편집]

class One(object):
	pass
class Dog(object):
	def __init__(self, name):
		self.name = name
	def bark(self):
		print 'Woof!'

myDog = Dog('snoopy')
myDog.bark()
# Woof!

4 Ruby[편집]

class Dog
end
class Dog
  isAlive = true
end
class Dog
  def initialize(name)
    @name = name
  end
	
  def bark
    puts "Woof!"
  end
end

myDog = Dog.new("snoopy");
myDog.bark

5 같이 보기[편집]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}