Class

  다른 뜻에 대해서는 클래스 문서를 참조하십시오.
  다른 뜻에 대해서는 typeof 문서를 참조하십시오.

1 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 }}