Class has no member named

前端 未结 9 1170
甜味超标
甜味超标 2021-02-19 01:00

I have a problem with accessing a function from a class with the class object in my main function. I am just trying to make the object for the class and use that ob

相关标签:
9条回答
  • 2021-02-19 01:55

    I had a similar problem. It turned out, I was including an old header file of the same name from an old folder. I deleted the old file changed the #include directive to point to my new file and all was good.

    0 讨论(0)
  • 2021-02-19 01:55

    Maybe I am 6.5 years late. But I'm answering because others maybe searching still now. I faced the same problem and was searching everywhere. But then I realized I had written my code in an empty file. If you create a project and write your code in there, there won't be this error.

    0 讨论(0)
  • 2021-02-19 01:55

    The reason that the error is occuring is because all the files are not being recognized as being in the same project directory. The easiest way to fix this is to simply create a new project.

    File -> Project -> Console application -> Next -> select C or C++ -> Name the project and select the folder to create the project in -> then click finish.

    Then to create the class and header files by clicking New -> Class. Give the class a name and uncheck "Use relative path." Make sure you are creating the class and header file in the same project folder.

    After these steps, the left side of the IDE will display the Sources and Headers folders, with main.cpp, theclassname.cpp, and theclassname.h all conviently arranged.

    0 讨论(0)
提交回复
热议问题