如何删除这些错误-请帮助我是C ++的新手 [英] how to remove these errore-please help i am new to c++

查看:85
本文介绍了如何删除这些错误-请帮助我是C ++的新手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码如下:

The code goes like this:

include<string>

using namespace System::IO;
include<iostream>

using namespace std;

class files { string *fname[25]; public: files() {*fname=NULL; }

};

class directory { private: directory *d; string *dname[25]; files *ff[25]; int numd,numf; public: directory() { numd=0;numf=0; } void search() { string *a[]=Directory::GetDirectories("D:\"); numd=a-&gt;get_length(); *dname[]=*a[]; for(int q=0;q

    for(int i=0;i&lt;numd;i++)
    { //find files
        string *b[]=Directory::GetFiles(d[i]);
            numf=b-&gt;get_length();
        files.*fname[]=*b[];
        for(int c=0;c&lt;numf;c++)
            cout&lt;&lt;files.*fname[c];

}
}

};

int main() { directory r; r.search(); return 0; }



错误如下:



the errors are as follows:

Error 1 error C2440: ''initializing'' : cannot convert from ''cli::array ^'' to ''std::string *[]'' c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 19

Error 2 error C2227: left of ''-&gt;get_length'' must point to class/struct/union/generic type c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 20

Error 3 error C2059: syntax error : '']'' c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 21

Error 4 error C2665: ''System::IO::Directory::GetFiles'' : none of the 3 overloads could convert all the argument types c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 28

Error 5 error C2227: left of ''-&gt;get_length'' must point to class/struct/union/generic type c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 29

Error 6 error C2143: syntax error : missing '';'' before ''.*'' c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 30

Error 7 error C2143: syntax error : missing '';'' before ''.*'' c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 30

Error 8 error C2065: ''fname'' : undeclared identifier c:\documents and settings\computer\my documents\visual studio 2008\projects\project\project\directory.h 32



请不要通过添加某种Boost库或.net来更改逻辑.我正在使用Visual c ++2008.我想坚持使用此代码.我期待着您的建议.请帮助我,因为这些指针已成为我的头等大事.如果有任何编辑错误,也请原谅.

[edit]将内联代码转换为代码块,大写-OriginalGriff [/edit]



Please don''t change the logic by adding some kind of boost library stuff or .net stuff. I am using visual c++ 2008. I want to stick to this code. I am looking forward for your suggestions. Please help me as these pointers are becoming a headacke for me. Also please forgive if there are any editing mistakes.

[edit]Inline code converted to code block, Capitalization - OriginalGriff[/edit]

推荐答案

我从哪里开始?

错误1:"b"不是指针. "b"是指向字符串的指针数组.要访问单个字符串,您需要取消引用.尝试改用"b [0]-> get_length()".它不起作用,因为您很有可能需要添加另一个循环,但是,嘿!这是你的逻辑.
错误2:(1)引起的
错误3:相同,但方式不同.

我会停在那里,你明白了.

回到一个阶段,尝试进入代码之前先思考一下自己在做什么.
Where do I start?

Error 1: "b" is not a pointer. "b" is an array of pointers to strings. To access an individual string, you need to derefence it. Try "b[0]->get_length()" instead. It won''t work, beacuse there is a good chance you need to add another loop, but hey! It''s your logic.
Error 2: Caused by (1)
Error 3: Same thing, a different way.

I''ll stop there, you get the idea.

Go back a stage, and try thinking about what you are doing before you leap into code.


这篇关于如何删除这些错误-请帮助我是C ++的新手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆