小编NBW*_*BWL的帖子

Fail to compile: strlen is not a member of std

I'm trying to compile this very simple program where I'm implementing a simplified version of C++ strings. However the compiler cannot find the std::strlen function even though I included

//main.cpp
#include "str.h"

int main()
{
    return 0;
}

// str.h
#ifndef _STRING_H_
#define _STRING_H_

#include <vector>
#include <cstring>
#include <algorithm>
#include <iterator>

class Str {
public:
    typedef std::vector<char>::size_type size_type;

    Str() { }
    Str(size_type n, char c): data(n, c) { }
    Str(const char* cp) {
        std::copy(cp, cp+std::strlen(cp), std::back_inserter(data));
    }
    template <class …
Run Code Online (Sandbox Code Playgroud)

c++ std strlen

1
推荐指数
1
解决办法
150
查看次数

标签 统计

c++ ×1

std ×1

strlen ×1