"Class"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 18개는 보이지 않습니다)
1번째 줄: 1번째 줄:
[[category:class]]
[[category:class]]
{{다른뜻|클래스}}
{{다른뜻|클래스}}
{{다른뜻|typeof}}


==JavaScript==
==JavaScript==
{{참고|JavaScript 클래스}}
[[분류: JavaScript]]
[[분류: JavaScript]]
<source lang='JavaScript'>
<syntaxhighlight lang='JavaScript'>
function Dog(name) {
function Dog(name) {
   this.name = name;
   this.name = name;
   this.bark = function() {
   this.bark = function() {
     console.log("Woof!");
     console.log("Woof! I'm " + this.name +".");
   }
   }
}
}
var myDog = new Dog("snoopy");
var myDog = new Dog("Snoopy");
myDog.bark();
myDog.bark();
// Woof!
// Woof! I'm Snoopy.
</source>
</syntaxhighlight>
<syntaxhighlight lang='JavaScript'>
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.
</syntaxhighlight>
<syntaxhighlight lang='JavaScript'>
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.
</syntaxhighlight>
<syntaxhighlight lang='JavaScript'>
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.
</syntaxhighlight>


==PHP==
==PHP==
[[분류: PHP]]
[[분류: PHP]]
<source lang='PHP'>
<syntaxhighlight lang='PHP'>
class Dog {
class Dog {
   public $name;
   public $name;
30번째 줄: 69번째 줄:
$myDog = new Dog("snoopy");
$myDog = new Dog("snoopy");
$myDog->bark();
$myDog->bark();
</source>
</syntaxhighlight>


==Python==
==Python==
[[분류: Python]]
[[분류: Python]]
<source lang='Python'>
<syntaxhighlight lang='Python'>
class One(object):
pass
</syntaxhighlight>
<syntaxhighlight lang='Python'>
class Dog(object):
class Dog(object):
def __init__(name):
def __init__(self, name):
self.name = name
self.name = name
def bark(self):
print 'Woof!'


def bark():
myDog = Dog('snoopy')
print "Woof!"
myDog.bark()
# Woof!
</syntaxhighlight>


myDog = Dog("snoopy");
==Ruby==
myDog.bark()
[[분류: Ruby]]
</source>
<syntaxhighlight lang='Ruby'>
class Dog
end
</syntaxhighlight>
<syntaxhighlight lang='Ruby'>
class Dog
  isAlive = true
end
</syntaxhighlight>
<syntaxhighlight lang='Ruby'>
class Dog
  def initialize(name)
    @name = name
  end
  def bark
    puts "Woof!"
  end
end
 
myDog = Dog.new("snoopy");
myDog.bark
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[클래스]]
*[[클래스]]
*[[Hello 클래스]]
*[[new object]]
*[[new object]]
*[[constructor]]
*[[constructor]]
55번째 줄: 125번째 줄:
*[[method_exists]]
*[[method_exists]]
*[[class constant]]
*[[class constant]]
*[[typeof]]
*[[this]]

2020년 11월 2일 (월) 02:31 기준 최신판

  다른 뜻에 대해서는 클래스 문서를 참조하십시오.
  다른 뜻에 대해서는 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 }}