c++ - 无法使用 STL 的字符串类

标签 c++ string stl

以前遇到过这个问题,但是忘了是怎么解决的

我想使用 STL 字符串类,但编译器提示找不到它。 这是完整的 .h 文件。

#ifndef MODEL_H
#define MODEL_H

#include "../shared/gltools.h"  // OpenGL toolkit
#include <math.h>
#include <stdio.h>
#include <string>
#include <iostream>

#include "Types.h"

class Model
{

public:

    obj_type_ptr p_object;
    char Load3DS (char *p_filename);
    int LoadBitmap(char *filename);

    int num_texture;
    string fun("alex");

    Model(char* modelName, char* textureFileName);
};

#endif

最佳答案

你想使用 std::string,是吗?

您只是在使用 string。如果你有一个 using namespace ... 声明,这会起作用,但在头文件中并不是一个好主意。

关于c++ - 无法使用 STL 的字符串类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2226412/

相关文章:

c++ - 我们有一个国际标准 : C++0x is unanimously approved. 我在哪里可以找到最新的草案/拷贝?

c++ - 如何将 boost::weak_ptr 转换为 boost::shared_ptr

C++自动推导返回类型

linux - 使用管道时类似于字符串操作的基本名称

c++ - map 的 std::for_each() 给出无效的初始化错误

c++ - qDebug 将 QString UTF-8 非 Ascii 符号输出为 like\uxxxx

Java括号替换为空字符串

string - 为什么我们不能一次性可靠地测试回文

C++ 按值删除 vector 元素

c++ - set::find 和 <algorithm> find 之间的性能差异