Never seen this before.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 #ifndef SEQ_H
#define SEQ_H
#define INIT_VAL "A1"

#include<vector>
#include<string>

using std::string;
using std::vector;

class SEQ
{
private:
	string id;
public:
	SEQ(const string& x= INIT_VAL) : id(x){}
	string operator()()
	{
		string tmp=id;
		if(id[1]<'9') id [1]++;
		else {id[0]++; id[1]='1';}
		return tmp;
	}
};


Can someone explain what string operator ()() is?(line 17) And how does the SEQ constructor work? (line 16)Thanks.
Last edited on
Hi Cody,

Line 16 has default value - if no argument is supplied it will use this value. It type is const std::string reference. There is also an initialiser list (introduced with the colon) which sets the member id with he value of x

Line 17 I Don't really know mauch about the details of this, but it looks like it is an overload of the operator () with an empty argument list (the second pair of parentheses).

HTH
Topic archived. No new replies allowed.