Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy am I getting this eror?
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/6661257/error-c2248-stdbasic-ios-elem-traitsbasic-ios-cannot-access-private">error C2248: ‘std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios’ : cannot access private member declared in class ‘std::basic_ios&lt;_Elem,_Traits&gt;’</a> </p> </blockquote> <pre><code>error C2248: 'std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios' : cannot access private member declared in class 'std::basic_ios&lt;_Elem,_Traits&gt;' </code></pre> <p>What I'm supposed to be doing with this code is opening two file, reading the files, calculating the mean and standard deviation from the numbers inside of that file with functions and arrays. So, I am getting this error and I'm not really sure what is wrong with my code. I'm not really sure what is wrong with the code but it could possible be the functions? My friend took a look at my code and got that error but it wasn't there before. Am I supposed to do a reference somewhere but I made it a value instead? Could anyone help? Sorry if I did something wrong while making this post.</p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;cmath&gt; #include &lt;string&gt; #include &lt;iomanip&gt; using namespace std ; bool open(ifstream &amp;A_bank, ifstream &amp;B_bank) ; void read(ifstream &amp;A_bank, ifstream &amp;B_bank, string &amp;n1, string&amp; n2, int &amp;i, int&amp; j, float &amp;num, float &amp;num1, float &amp;total, float &amp;total1, float counter, float counter1); void avg(float &amp;mean, float &amp;mean1, float total, float total1, int i, int j); void print(ifstream A_bank, ifstream B_bank, float mean, float mean1, string n1, string n2); int main() { //Declaring variables. ifstream A_bank, B_bank ; string n1,n2; int i, j, a[20], b[20] ; float num=0, num1=0, total=0, total1=0, stdev=0,stdev1=0, mean=0, mean1=0, counter, counter1 ; open(A_bank, B_bank) ; read(A_bank, B_bank, n1, n2, i, j, num, num1, total, total1, counter, counter1) ; avg(mean, mean1, total, total1, i, j) ; print(A_bank, B_bank, mean, mean1, n1, n2) ; return 0; } bool open(ifstream &amp;A_bank, ifstream &amp;B_bank) { string n1, n2; cout &lt;&lt; "Enter file name: " ; getline(cin, n1) ; A_bank.open(n1.c_str()) ; if (A_bank.eof()) { cout &lt;&lt; "File is empty" &lt;&lt; endl ; return false ; } //Verify that the correct file name was entered. else if (A_bank.fail()) { cout &lt;&lt; "File could not be opened." &lt;&lt; endl ; return false ; } cout &lt;&lt; "Enter file name of second bank: " ; getline(cin, n2) ; B_bank.open(n2.c_str()) ; if (B_bank.eof()) { cout &lt;&lt; "File is empty" &lt;&lt; endl ; return false ; } else if (B_bank.fail()) { cout &lt;&lt; "File could not be opened." &lt;&lt; endl ; return false ; } return true ; } //Reading the files void read(ifstream &amp;A_bank, ifstream &amp;B_bank, string &amp;n1, string&amp; n2, int &amp;i, int&amp; j, float &amp;num, float &amp;num1, float &amp;total, float &amp;total1, float counter, float counter1, int a[], int b[]) { getline(A_bank,n1); for(int i=0; !A_bank.eof();i++) { A_bank&gt;&gt;a[i]; total+=a[i]; counter++; } getline(B_bank,n2); for(int j=0; !B_bank.eof();j++) { B_bank&gt;&gt;b[j]; total+=b[j]; counter1++; } } //Calculations void avg(float &amp;mean, float &amp;mean1, float total, float total1, int i, int j) { mean = (total) / (i) ; mean1 = (total1) / (j) ; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    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