c++ 생성자 변수 초기화(?) 질문

siera1의 이미지

정확하게는 생성자 변수 초기화 질문이 아니고, 변수 초기화 하는 자리에 있는 또 다른 클래스 명 때문에 질문합니다.

제가 c++ 코드가 어색하고 문법공부를 제대로 하지 않아서 초보적인 질문일 수 있습니다...

요즘 제가 보고 있는 오도메트리 오픈소스 중 일부인데요.

아래에 DepthSource라는 class가 있습니다.

class DepthSource
{
  public:
 
    virtual bool haveXyz(int u, int v) = 0;
 
    virtual void getXyz(OdometryFrame * frame) = 0;
 
    virtual void refineXyz(FeatureMatch * matches,
                           int num_matches,
                           OdometryFrame * frame) = 0;
    // (생략)
}

근데 다른 cpp 파일에 보니 DepthImage 라는 아래와 같은 애가 있습니다.

class DepthImage : public DepthSource
{
	public:
		DepthImage(const CameraIntrinsicsParameters& rgb_camera_params,
			int depth_width, int depth_height);
		~DepthImage();
 
		/**
		* Set the depth image, a width x height array of distances, units given in
		* meters.  Each pixel of the depth image corresponds to a point in the
		* rectified RGB image.
		*/
		void setDepthImage(const float* depth_data);
 
		virtual bool haveXyz(int u, int v) ;
		virtual void getXyz(OdometryFrame * frame);
		virtual void refineXyz(FeatureMatch * matches,
			int num_matches,
			OdometryFrame * frame);
 
		virtual double getBaseline() const { return 0; }
                //(생략)
}

':' 요거 뒤에 있는 애는 변수 초기화라고 알고 있는데 저렇게 그냥 함수가 들어오면 뭔가요?

DepthImage를 생성하면 DepthSource도 생성되는건가요?

http://msdn.microsoft.com/ko-kr/library/s16xw1a8.aspx 에 나온대로라면 DepthSource는 가상이라는 말인지..

그러면 DepthImage 클래스의 public: DepthImage 옆에 DepthSource도 있어야되는거 아닌가요?

제가 결국 하고 싶은건 저 DepthSource라는 클래스 타입의 변수를 만들고 싶은것인데,

저렇게 DepthImage 클래스 생성할때 꼽사리처럼 생성이 되면 변수 선언은 어떻게 해야하는 건가요?

도와주세요!

klara의 이미지

여기에서 public: 이란 접근 한정자를 지정하는 구문입니다.

그냥 C++입문서를 하나 읽으시는게 좋을텐데요...
아무리 다른 언어를해서 객체지향을 안다고 해도 C++은 반드시 입문서 정독해야만 쓸수 있는 언어입니다.
대충 배워서 대충 쓰다가는 그냥 망합니다.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.