Pointers to elements of a C++ class

<p>I have a <strong>C++</strong> class <em>c_image</em> which contains a vector of pointers to elements of class <em>c_pixel</em>:</p><pre><br /><code>class c_image {<br /><br /> public:<br /> vector<shared_ptr<c_pixel>> pixel;<br /> ...<br />};<br /></code><br /></pre><p>Class <em>c_pixel</em> elements contain an element <em>Z</em> of type double:</p><pre><br /><code>class c_pixel {<br /><br /> public:<br /> double Z;<br /> ...<br />};<br /></code><br /></pre><p>However, they are extended with class <em>c_pixel_pv</em>, which contains <em>pv</em>, an array of three elements of type double:</p><pre><br /><code>class c_pixel_pv : public c_pixel {<br /><br /> public:<br /> double pv[3];<br /> ...<br />};<br /></code><br /></pre><p>Class <em>c_image</em> also has a function <em>filter</em></p><pre><br /><code>vector<double> c_image::filter(???) {<br /> ...<br /> };<br /></code><br /></pre><p>which will take as input a pointer to the elements <em>Z</em> or <em>pv[0]</em> or <em>pv[1]</em> or <em>pv[2]</em>.</p><p>But I have no idea how to point to these elements. I don't even know if it is possible to point, for example, only to <em>pv[0]</em> elements. I have no clue how to begin with this problem. Can anybody help me?</p><br /><h2>Click here view more answers <a href="%20http://stackoverflow.com/questions/34525474/pointers-to-elements-of-a-c-class">http://ift.tt/1Vpgopd</a></h2>

Nhận xét

Bài đăng phổ biến từ blog này

Align div to bottom of the page in bootstrap

Align elements inside an tag vertically

Javascript is unable to stop page loading