반응형
Qt C ++ 집계 'std :: stringstream ss'에 불완전한 유형이 있으며 정의 할 수 없습니다.
정수를 문자열로 변환하는 프로그램에이 함수가 있습니다.
QString Stats_Manager::convertInt(int num)
{
stringstream ss;
ss << num;
return ss.str();
}
그러나 이것을 실행할 때마다 오류가 발생합니다.
aggregate 'std::stringstream ss' has incomplete type and cannot be defined
그게 무슨 뜻인지 잘 모르겠습니다. 그러나 문제를 해결하는 방법을 알고 있거나 더 많은 코드가 필요하면 의견을 남겨주세요. 감사.
클래스의 포워드 선언이 있지만 헤더를 포함하지 않았습니다.
#include <sstream>
//...
QString Stats_Manager::convertInt(int num)
{
std::stringstream ss; // <-- also note namespace qualification
ss << num;
return ss.str();
}
거기 적힌 것처럼 타이핑하는 걸 잊었 어 #include <sstream>
#include <sstream>
using namespace std;
QString Stats_Manager::convertInt(int num)
{
stringstream ss;
ss << num;
return ss.str();
}
또한 변환하는 다른 방법을 사용할 수 있습니다 int
에 string
같은,
char numstr[21]; // enough to hold all numbers up to 64-bits
sprintf(numstr, "%d", age);
result = name + numstr;
반응형
'developer tip' 카테고리의 다른 글
Windows Forms C # 응용 프로그램에서 구성 파일을 사용하는 가장 간단한 방법 (0) | 2020.09.15 |
---|---|
libstdc ++. so.6 : 공유 객체 파일을 열 수 없음 : 해당 파일 또는 디렉토리 없음 (0) | 2020.09.15 |
Bash에서 eval을 피해야하는 이유는 무엇이며 대신 무엇을 사용해야합니까? (0) | 2020.09.14 |
CMake를 사용하여 Visual Studio C ++ 프로젝트 파일 생성 (0) | 2020.09.14 |
Maven의 명령 줄 인수를 pom.xml의 속성으로 전달 (0) | 2020.09.14 |