Why my program doesnt print ?
#include <iostream>
using namespace std;
class String {
string s;
public:
String(string ss): s(ss) {}
string substr(int pos = 0, int n = string::npos)
{
string str;
int j = 0;
for(int i = pos; i <= n; i++)
{
str[j] = s[i];
j++;
}
return str;
}
};
int main()
{
String test("i wanna be a milionar");
string obj = test.substr(3,6);
cout << obj;
}