疯狂的C++;关于来自MinGW32的复制构造函数的编译器错误消息 我是C++初学者,我使用JCKLN并安装了WINW32,因为我们把任务远程地转换成Linux机器,因此这有助于确保它通过模拟Windows环境中的Linux或其他东西来正常工作。对于明文32,我安装了“基本包”,然后手动选择C++编译器选项。在jGRASP中,我进入了settings>>PATH/CLASSPATH>>工作区,并在C:\MinGW\mingw32\bin中添加了一个新的路径目录,以便它知道g++编译器在哪里

疯狂的C++;关于来自MinGW32的复制构造函数的编译器错误消息 我是C++初学者,我使用JCKLN并安装了WINW32,因为我们把任务远程地转换成Linux机器,因此这有助于确保它通过模拟Windows环境中的Linux或其他东西来正常工作。对于明文32,我安装了“基本包”,然后手动选择C++编译器选项。在jGRASP中,我进入了settings>>PATH/CLASSPATH>>工作区,并在C:\MinGW\mingw32\bin中添加了一个新的路径目录,以便它知道g++编译器在哪里,c++,compiler-errors,mingw32,jgrasp,C++,Compiler Errors,Mingw32,Jgrasp,在jGRASP中编译时,我得到了这些疯狂的错误消息,我无法理解这些消息。我认为这与我的标题有关,因为iostream #include <string.h> #include <iostream> #include <iomanip> #include <fstream> using namespace std; #包括 #包括 #包括 #包括 使用名称空间std; 以下是编译器错误消息: ios:42:0,

在jGRASP中编译时,我得到了这些疯狂的错误消息,我无法理解这些消息。我认为这与我的标题有关,因为iostream

#include <string.h>
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
#包括
#包括
#包括
#包括
使用名称空间std;
以下是编译器错误消息:

ios:42:0,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\ostream:38,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iostream:39,
                 from lab1.cpp:6:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\ios_base.h: In copy constructor 'std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)':
ios_base.h:786:5: error: 'std::ios_base::ios_base(const std::ios_base&)' is private
     ios_base(const ios_base&);
     ^
ios:44:0,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\ostream:38,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iostream:39,
                 from lab1.cpp:6:
basic_ios.h:66:11: error: within this context
     class basic_ios : public ios_base
           ^
In file included from lab1.cpp:8:0:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\fstream: In copy constructor 'std::basic_ifstream<char>::basic_ifstream(const std::basic_ifstream<char>&)':
fstream:427:11: note: synthesized method 'std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)' first required here 
     class basic_ifstream : public basic_istream<_CharT, _Traits>
           ^
ios:43:0,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\ostream:38,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iostream:39,
                 from lab1.cpp:6:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\streambuf: In copy constructor 'std::basic_filebuf<char>::basic_filebuf(const std::basic_filebuf<char>&)':
streambuf:802:7: error: 'std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char; _Traits = std::char_traits<char>]' is private
       basic_streambuf(const basic_streambuf& __sb)
       ^
In file included from lab1.cpp:8:0:
fstream:72:11: error: within this context
     class basic_filebuf : public basic_streambuf<_CharT, _Traits>
           ^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\fstream: In copy constructor 'std::basic_ifstream<char>::basic_ifstream(const std::basic_ifstream<char>&)':
fstream:427:11: note: synthesized method 'std::basic_filebuf<char>::basic_filebuf(const std::basic_filebuf<char>&)' first required here 
     class basic_ifstream : public basic_istream<_CharT, _Traits>
ios:42:0,
从c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\ostream:38,
从c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iostream:39,
从lab1.cpp:6:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\ios\u base.h:在复制构造函数“std::basic\u ios::basic\u ios(const std::basic\u ios&)”中:
ios_base.h:786:5:错误:“std::ios_base::ios_base(const std::ios_base&)”是私有的
ios_base(const ios_base&);
^
ios:44:0,
从c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\ostream:38,
从c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iostream:39,
从lab1.cpp:6:
basic_ios.h:66:11:错误:在此上下文中
类基本ios:公共ios基础
^
在lab1.cpp中包含的文件中:8:0:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\fstream:在复制构造函数“std::basic\u ifstream::basic\u ifstream(const std::basic\u ifstream&)”中:
fstream:427:11:注意:这里首先需要合成方法“std::basic_ios::basic_ios(const std::basic_ios&)”
类基本流:公共基本流
^
ios:43:0,
从c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\ostream:38,
从c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iostream:39,
从lab1.cpp:6:
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\streambuf:在复制构造函数“std::basic_filebuf::basic_filebuf(const std::basic_filebuf&)”中:
streambuf:802:7:错误:“std::basic\u streambuf::basic\u streambuf(const std::basic\u streambuf&)[with(with)CharT=char;_Traits=std::char\u Traits]”是私有的
基本流量(const基本流量和sb)
^
在lab1.cpp中包含的文件中:8:0:
fstream:72:11:错误:在此上下文中
类基本文件:公共基本文件
^
c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\fstream:在复制构造函数“std::basic\u ifstream::basic\u ifstream(const std::basic\u ifstream&)”中:
fstream:427:11:注意:这里首先需要合成方法'std::basic_filebuf::basic_filebuf(const std::basic_filebuf&')
类基本流:公共基本流
这是我到目前为止的代码:

// ----------------------------------------------------------------------------
// You write meaningful doxygen comments and assumptions

#include <string.h>
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

int const MAXSIZE = 100;            // maximum number of records in total
int const MAXLENGTH = 31;           // maximum string length 
int const MAXGRADE = 100;           // highest possible grade
int const LOWGRADE = 0;             // lowest possible grade
int const GROUP = 10;               // group amount
int const HISTOGRAMSIZE = (MAXGRADE-LOWGRADE)/GROUP + 1;    // grouped by GROUP

struct StudentType  {               // information of one student
   int grade;                       // the grade of the student
   char last[MAXLENGTH];            // last name (MAXLENGTH-1 at most)
   char first[MAXLENGTH];           // first name (MAXLENGTH-1 at most)
};

// prototypes go here
bool sortInput(ifstream, StudentType, int);
void displayList(StudentType, int);
/*setHistrogram();
displayHistogram();
findAverage();*/

//------------------------------- main ----------------------------------------
int main()  {
   StudentType students[MAXSIZE];   // list of MAXSIZE number of students
   int size = 0;                    // total number of students
   int histogram[HISTOGRAMSIZE];    // grades grouped by GROUP
   int average = 0;                 // average exam score, truncated

   // creates file object and opens the data file
   ifstream infile("data1.txt");
   if (!infile)  { 
      cout << "File could not be opened." << endl; 
      return 1;  
   }

   // read and sort input by last then first name
   bool successfulRead = sortInput(infile, students, size);              

   // display list, histogram, and class average 
   if (successfulRead)  {
      displayList(students[], size);
     // setHistogram(... you figure parameters ...);
     // displayHistogram(... you figure parameters ...);
     // average = findAverage(... you figure parameters ...);
      cout << "Average grade: " << average << endl << endl;
   }
   return 0;
}

bool sortInput(ifstream infile, StudentType students[], int size)
{
   while(infile)
   {
      StudentType temp;
      infile >> temp.last >> temp.first >> temp.grade;

      //for(int i = MAXSIZE-1; i > MAXSIZE-1-size; i--)
      for(int i = size; i > 0; i--)
      {
         if(strcmp(temp.last, students[i].last) < 0)
         {
            //copy current name and grade down
            //strcopy(students[i+1].last, students[i].last);
            students[i+1] = students[i];
         }
         else if(strcmp(temp.last, students[i].last) == 0 && strcmp(temp.first, students[i].first) < 0))
         {
            //copy/assign current name and grade down
            students[i+1] = students[i];
         }
         else
         {
            //found right place, break out of loop
            break;
         }
      }

      //now that you've made room, insert (copy) new name into correct sorted position
      students[i] = temp;
   }

   return true;
}

void displayList(StudentType students[], int size)
{
   cout << "List of names sorted:" << end1;

   for(int i = 0; i < size; i++)
   {
      cout << " " << student[i].grade << " " << students[].last << " " << students[i].first << end1;
   }
}

// ----------------------------------------------------------------------------
// functions with meaningful doxygen comments and assumptions go here
//----------------------------------------------------------------------------
//您可以编写有意义的doxygen注释和假设
#包括
#包括
#包括
#包括
使用名称空间std;
int const MAXSIZE=100;//总记录数的最大值
int const MAXLENGTH=31;//最大字符串长度
int const MAXGRADE=100;//最高等级
int const LOWGRADE=0;//最低可能等级
int const GROUP=10;//组数
int const historogramize=(MAXGRADE-LOWGRADE)/组+1;//分组
struct StudentType{//一个学生的信息
int grade;//学生的成绩
char last[MAXLENGTH];//姓氏(最多MAXLENGTH-1)
char first[MAXLENGTH];//名字(最多MAXLENGTH-1)
};
//我去这里
bool-sortInput(ifstream、StudentType、int);
无效显示列表(StudentType,int);
/*setHistrogram();
显示直方图();
findAverage()*/
//-------------------------------主要----------------------------------------
int main(){
StudentType students[MAXSIZE];//MAXSIZE学生人数列表
int size=0;//学生总数
int直方图[HISTOGRAMSIZE];//按组分组的等级
int average=0;//平均考试分数,截断
//创建文件对象并打开数据文件
ifstream-infle(“data1.txt”);
如果(!infle){
温度等级;
//对于(int i=MAXSIZE-1;i>MAXSIZE-1-size;i--)
对于(int i=size;i>0;i--)
{
if(strcmp(临时最后,学生[i].last)<0)
{
//向下复制当前名称和等级
//strcopy(students[i+1]。last,students[i]。last);
学生[i+1]=学生[i];
}
else if(strcmp(temp.last,students[i].last)==0&&strcmp(temp.first,students[i].first)<0))
{
//复制/分配当前名称并降级
学生[i+1]=学生[i];
}
其他的
{
//找到正确的位置,打破循环
打破
}
}
//现在您已经腾出了空间,将新名称插入(复制)到正确的排序位置
学生[i]=临时工;
}
返回true;
}
无效显示列表(StudentType students[],整数大小)
{

我自己也遇到过。问题是,
sortInput
按值而不是按引用获取
ifstream
ifstream
s不喜欢被复制。只需将声明更改为:

bool sortInput(ifstream&, StudentType, int);

注意&

请显示代码。可能有问题。不确定…尝试删除(注释掉)所有代码,除了空的
函数和
包含
并使用
语句。然后尝试执行干净的编译。(意思是删除和可执行代码和
*。obj