#include <iostream>
#include<stdio.h>
#include<vector>
using namespace std;
class String
{
private:
vector<char> s;
int len;
public:
String String::substr(int pos, int nchar)const
{
String tach(nchar);
for (int i = pos; i <= (pos+nchar); i++)
{
tach.s[i-pos] = this->s[i];
}
return tach;
}
Vì sao khi em cho s là const char* thì hàm substr chạy bình thường mà nếu s là vector như trên thì bị lỗi ạ??
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?