Note that there are some explanatory texts on larger screens.

plurals
  1. POc++ vektor always gives 0
    primarykey
    data
    text
    <p>my first.h:</p> <pre><code>class skaiciavimas { public: vector&lt;int&gt; vekto[2]; skaiciavimas(); ~skaiciavimas(); .... </code></pre> <p>my first.cpp</p> <pre><code> #include "skaiciavimas.h" skaiciavimas::skaiciavimas() { int i; for(i=0;i&lt;2;i++) vekto[i].resize(3); } void skaiciavimas::showst(vector&lt;int&gt; st,int i) { vekto[i].at(0)=st.at(0); vekto[i].at(1)=st.at(1); vekto[i].at(2)=st.at(2); cout&lt;&lt;vekto[1].at(0)&lt;&lt;vekto[0].at(0)&lt;&lt;endl; } void skaiciavimas::tikrinimas () { cout&lt;&lt;vekto[1].at(0)&lt;&lt;vekto[0].at(0)&lt;&lt;endl;// gives always 0,0 .... </code></pre> <p>there is second class from where i call shwst function second.cpp:</p> <pre><code>vandenynas::vandenynas() { vektorV.resize(3); } void vandenynas::duomenys (int i, int a, int a0) { switch (i) { case 0: vektorV.at(0)=a-a0; break; case 1: vektorV.at(1)=a-a0; break; default: vektorV.at(2)=a-a0; break; } sk.showst(vektorV,0); } </code></pre> <p>the tikrinimas function i call from my main:</p> <pre><code>sk.tikrinimas(); </code></pre> <p>why this line </p> <pre><code>cout&lt;&lt;vekto[1].at(0)&lt;&lt;vekto[0].at(0)&lt;&lt;endl; </code></pre> <p>alvays gives me 00, how to correct that to get the rigt numbers wich were assign in showst</p> <p>P.S sk is my class (first sk;)</p> <p>there is called duomenys and tikrinimas :</p> <pre><code>vandenynas vand; skaiciavimas sk; int main() { int i,a,a0,t; int j=1; while (j&lt;3) { for (i=0;i&lt;3;i++) { cout&lt;&lt;"enter "&lt;&lt;kas&lt;&lt;kint(i)&lt;&lt;" kordinates"&lt;&lt;endl; cout&lt;&lt;kint(i)&lt;&lt;"0 = "; cin&gt;&gt;a0; cout&lt;&lt;kint(i)&lt;&lt;" = "; cin&gt;&gt;a; cout&lt;&lt;endl; if (j==1) vand.duomenys(i,a,a0); } j++; } sk.tikrinimas(); ... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload