C++ 에서 모르겠는 문법이 나왔습니다.

Geniys의 이미지

코드가 다음과 같은데 궁금한게 있습니다.

Profile::Profile(	Point2 &p_o,	realno &p_w, 
						realno &p_h,	 realno& p_grad,
						PointVector &pnts,	Point2 &d) : 
						PointVector(NO_CONTROL_POINTS+1), 
						Observation(), 
						direction(point_data()[NO_CONTROL_POINTS])
	{
		spline_weights = NULL;
		origin = p_o;
		width = p_w;
		height = p_h;
		
		Observation::xlo = real_to_int(origin.x - width / 2);
		Observation::xhi = real_to_int(origin.x + width / 2);
		Observation::ylo = real_to_int(origin.y - height / 2);

위 코드에서 보면 Profile 클래스가 Observation 클래스를 상속받습니다.
상속받으면 그 변수가 포함되는데 굳이 앞에 클래스 이름을 쓰는 것은 어떤 이유인지 궁금합니다.

Observation::xlo = 13;

위엣 부분이 궁금합니다.

익명 사용자의 이미지

분명하면서 가독성을 높이기 위해서 붙이는 것 같습니다.

pynoos의 이미지

가독성이 높아 집니다.

같은 이유로, 최근 헝가리안 표기법의 m_ 대신 this-> 를 사용하여 멤버를 표시하는 방법도 소개되었습니다.
아마 MS의 개발자였죠?

자룡의 이미지

Profile::Profile(   Point2 &p_o,   realno &p_w,
                  realno &p_h,    realno& p_grad,
                  PointVector &pnts,   Point2 &d) :
                  PointVector(NO_CONTROL_POINTS+1),
                  Observation(),
                  direction(point_data()[NO_CONTROL_POINTS]) 

Profile 의 베이스 클래스가 Observation 이라면
위에서 Profile 의 베이스 클래스인 Observation 을
변수 초기화 시키는 것은 어떤 의미가 있나요?

Profile 의 생성자가 호출되면서 Observation 생성자 또한
호출될거라 생각되는데..

Observation 의 생성자가 여러개라서 특정 생성자를 이용하겠다는 뜻인지...?

궁금하네요.. ^^;;

-----
이글을 읽는 모든 이에게 평화가 함께 하기를... ^^;

only2sea의 이미지

다중 상속 등을 통하여 모호성이 생길 때, 사용하기도 합니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.