奇怪的错误:“错误:从'std :: ifstream到'const char *'[-fpermissive] |的无效用户定义转换?”

时间:2018-09-02 20:13:24

标签: c++

对于我正在制作的程序,我必须使用文件输入。用户必须输入包含名称列表的文件的名称。输入名称时,名称的数量应由计数器计算出来,然后显示数量。但是,我在使用函数“ int预处理”时遇到了麻烦,应该执行上述操作。

我收到错误“错误:从'std :: ifstream到'const char *'[-fpermissive] |的无效用户定义转换?”在“ fileName.open(fileName);”行上在头文件中。我不知道怎么了。

这是我的主要爱好:

    private void FinalFrame_NewFrame(object sender, NewFrameEventArgs eventArgs)
    {
        pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone();
        System.Drawing.Image img = pictureBox1.Image;

        var bm = new Bitmap(pictureBox1.Bounds.Width,
                            pictureBox1.Bounds.Height,
                            PixelFormat.Format32bppArgb);
        var gfxScreenshot = Graphics.FromImage(bm);
        gfxScreenshot.CopyFromScreen(this.pictureBox1.Bounds.X,
                                    this.pictureBox1.Bounds.Y,
                                    0,
                                    0,
                                    this.pictureBox1.Bounds.Size,
                                    CopyPixelOperation.SourceCopy);
        BitmapData srcData = bm.LockBits(
        new Rectangle(0, 0, bm.Width, bm.Height),
        ImageLockMode.ReadOnly,
        PixelFormat.Format32bppArgb);
        UnmanagedImage unmanagedImg = new UnmanagedImage(srcData);
        //Gray Image
        UnmanagedImage grayImage = UnmanagedImage.Create(bm.Width, bm.Height, PixelFormat.Format8bppIndexed);
        Grayscale.CommonAlgorithms.BT709.Apply(unmanagedImg, grayImage);
        pictureBox2.Image = grayImage.ToManagedImage();
    }

这是我的头文件,其中包含以下功能:

#include<iostream>
#include<string>
#include "names.h"
using namespace std;

//Do not modify main

int main(){
   int nameCount;
   string filename;
   //open file, find out how many names...
   cout<<"Enter the name of the file: ";
   cin>>filename;//assumption:  file has no spaces in it.
   nameCount = preprocessing(filename);

   //now, the real work begins...
   string *names = new string[nameCount];
   read(filename, names, nameCount);

   cout<<"Names in file order: "<<endl;
   print(names, nameCount);

   //sort names by first name:
   sort(names, nameCount);
   //print names in sorted order:
   cout<<endl<<endl<<"Names in alphabetical order, by first name: "<<endl;
   print(names, nameCount);

   //put names in LAST, FIRST order
   nameInvert(names, nameCount);

   //call sort again, since name format has changed to LAST, FIRST
   sort(names, nameCount);
   //print names in sorted order:
   cout<<endl<<endl<<"Names in alphabetical order, by last name: "<<endl;
   print(names, nameCount);
   cout<<endl;


   return 0;
}

0 个答案:

没有答案