Given you're using std::string you have many easy alternatives:
1. Use
basic_string substr(size_type pos = 0, size_type n = npos) const;
Returns a string composed of copies of the lesser of
n and
size() characters in this string starting at index
pos.
Throws an
out_
of_
range exception if
pos >
size().
2. Use this constructor which creates new string object using a substring of an existing strnig object: basic_string (const basic_string& str, size_type pos, size_type n= npos, const allocator& a=allocator());
If you're really concerned abt teh performance, you might wann use char* instead of std::string. In this case if you want to pass a sub string, the begin part can be taken care of by pointer arithmatic. The end part is tricky and it would be best (in terms of performance) if you pass another integer to indicate the end.
E.g.
void comlex_func( char* equetion, const int length ) ;
int main()
{
char equation[] = "1+2+3*4" ;
//say we want to pass "2+3" part to function.
comlex_func( equation + 3, 3 ) ;
return 0;
}