5 | src/configuration.h:15:35: error: ‘string’ in namespace ‘std’ does not name a type 15 | vo …
+ 여기에 자세히 보기
Source: github.com
Date Published: 5/14/2021
View: 7055
주제와 관련된 이미지 c++ string does not name a type
주제와 관련된 더 많은 사진을 참조하십시오 c++ error,does not name a type. . 댓글에서 더 많은 관련 이미지를 보거나 필요한 경우 더 많은 관련 기사를 볼 수 있습니다.
c++ error,does not name a type.
주제에 대한 기사 평가 c++ string does not name a type
Author: CSE
Views: 조회수 3,124회
Likes: 좋아요 9개
Date Published: 2021. 5. 11.
Video Url link: https://www.youtube.com/watch?v=74tIVyVEm1g
Why am I getting string does not name a type Error?
Your using declaration is in game.cpp , not game.h where you actually declare string variables. You intended to put using namespace std; into the header, above the lines that use string , which would let those lines find the string type defined in the std namespace.
As others have pointed out, this is not good practice in headers — everyone who includes that header will also involuntarily hit the using line and import std into their namespace; the right solution is to change those lines to use std::string instead
‘string’ does not name a type
Mar 8, 2012 at 9:47pm UTC LB (13399)
Change “string” to “std::string”
Most likely you did not mean to comment out line 12.
Also, what your professor told you only applies when you have optimizations on – in debug mode (no optimizations) it does not apply.
‘string’ does not name a type
OK, I’ve seen this error explained at least 100 times on the net. But in every case, it seems to be an error of #including instead of or metioning string instead of std::string. But, I’ve done all those things. And it still does not work.
By way of background: I am a LONG time newbie C++ programmer (meaning that I write code in spurts and then not at all for several years, which means that whenever I advance beyond newbie status, I slide back after time). I have also traditionally been coding using the old Borland compiler (which works, even if it is ancient, but I like the IDE). I have now been trying to come into the 21st century by using gnu c++ (g++ and mingw). The code problem that I am presenting compiles using the Borland compiler, but gives me the error message only when I try to compile with g++.
The problem code:
#ifndef ERRORHANDLER_H #define ERRORHANDLER_H #define DOS #include #include #include #include #include #include class ErrorReport { private: std::string logfilename; public: void set (const std::string name) {logfilename=name;}; std::string file() const {return logfilename;}; std::string GetNow() const { std::string now; char date [10]; _strdate(date); char time [10]; _strtime(time); now= date; now+= ” “; now+= time; now+= ” “; return now; }; . . .
You can see I use std::string and have this header protected with an #ifndef envelope. I am not using namespace in the header, which people tell me is a bad thing to do.
So, any suggestions??
Thanks for your time.
What is the error: ‘string’ does not name a type in c++ problem, and how to solve it?
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
C++ – error: ‘string’ in namespace ‘std’ does not name a type – iTecNote
I have this 2 separated class and i cant fix this compiler problem:
In file included from classA.cpp:2:0:
classB.h:6:10: error: ‘string’ in namespace ‘std’ does not name a type
std::string str;
^
In file included from classA.cpp:3:0:
classA.h:6:25: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
classB *ptr_b = new classB;
How to use string as type in header file in C++
I wanna use string as a type in my class header file, but even with and without the string lib, it shows me: error: ‘string’ does not name a type How can I use string in the header?
Caused by the “error string in namespace std does not name a type” error
struct sales_data { std::string bookNo; std::string bookName; unsigned int count; double price; }; int main() { return 0; }
A weird thing happened when I was learning c++ today: when compiling the following code, the compiler displayed an error:error: ‘string’ in namespace ‘std’ does not name a typeThe procedure is as follows:
obviously there is a #include< string>
However, if you modify the code as shown below, you will also compile successfully.
The modified code is as follows:
#include struct sales_data { std::string bookNo; std::string bookName; unsigned int count; double price; }; int main() { return 0; }
what is the reason for this?
After Google, at http://www.cplusplus.com/ query to the ios libraries and other libraries relationship is as follows:
As you can see from the figure above, the StringStream library has been declared in the IoStream library and includes some of the string functionality. So that’s what happened.
Code is broken with gcc 10.1 in src/configuration.cpp · Issue #165 · ColinPitrat/caprice32
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Pick a username Email Address Password Sign up for GitHub
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
키워드에 대한 정보 c++ string does not name a type
다음은 Bing에서 c++ string does not name a type 주제에 대한 검색 결과입니다. 필요한 경우 더 읽을 수 있습니다.
이 기사는 인터넷의 다양한 출처에서 편집되었습니다. 이 기사가 유용했기를 바랍니다. 이 기사가 유용하다고 생각되면 공유하십시오. 매우 감사합니다!
사람들이 주제에 대해 자주 검색하는 키워드 c++ error,does not name a type.
c++ #error,does #not #name #a #type.
YouTube에서 c++ string does not name a type 주제의 다른 동영상 보기
주제에 대한 기사를 시청해 주셔서 감사합니다 c++ error,does not name a type. | c++ string does not name a type , 이 기사가 유용하다고 생각되면 공유하십시오, 매우 감사합니다.