For faster navigation, this Iframe is preloading the Wikiwand page for
멤버 변수.
객체 지향 프로그래밍에서 멤버 변수(member variable) 또는 멤버 필드는 특정 객체와 연결된 변수의 하나이며, 해당 변수의 모든 메소드(멤버 함수)에 접근이 가능하다. 클래스 기반 언어에서 이들은 두 종류로 구별된다: 모든 인스턴스의 클래스와 공유되는 변수의 사본이 하나만 있을 경우 이를 클래스 변수나 정적 멤버 변수로 부른다. 클래스의 각 인스턴스가 자신만의 변수 복사본을 소유하고 있는 경우 해당 변수는 인스턴스 변수라 부른다.[1]
#include <iostream>
class Foo {
int bar; // 멤버 변수
public:
void setBar (const int newBar) { bar = newBar; }
};
int main () {
Foo rect; // 지역 변수
return 0;
}
class Program
{
static void main(final String arguments[])
{
// 이것은 로컬 변수이다. 이 변수의 수명은
// 어휘 범위에 의하여 결정된다.
Foo foo;
}
}
class Foo
{
// 이것은 멤버 변수이다. 이 변수의 새로운
// 인스턴스는 Foo의 각각의 새로운
// 인스턴스들을 위해 만들어진다. 이 변수의
// 수명은 Foo의 "this" 인스턴스의 수명과
// 동일하다.
int bar;
}
- ↑ Richard G. Baldwin (1999년 3월 10일). “Q - What is a member variable?”. http://www.dickbaldwin.com/: Richard G Baldwin Programming Tutorials. 2011년 8월 12일에 확인함.
A member variable is a member of a class (class variable) or a member of an object instantiated from that class (instance variable). It must be declared within a class, but not within the body of a method of the class.
{{bottomLinkPreText}}
{{bottomLinkText}}
This page is based on a Wikipedia article written by
contributors (read/edit).
Text is available under the
CC BY-SA 4.0 license; additional terms may apply.
Images, videos and audio are available under their respective licenses.
{{current.index+1}} of {{items.length}}
Thanks for reporting this video!
This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:
An extension you use may be preventing Wikiwand articles from loading properly.
If you're using HTTPS Everywhere or you're unable to access any article on Wikiwand, please consider switching to HTTPS (https://www.wikiwand.com).
An extension you use may be preventing Wikiwand articles from loading properly.
If you are using an Ad-Blocker, it might have mistakenly blocked our content.
You will need to temporarily disable your Ad-blocker to view this page.
✕
This article was just edited, click to reload
Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}
Follow Us
Don't forget to rate us
Oh no, there's been an error
Please help us solve this error by emailing us at
support@wikiwand.com
Let us know what you've done that caused this error, what browser you're using, and whether you have any special extensions/add-ons installed.
Thank you!