Error C3867 assign': non-standard syntax; use '&' to create a pointer to member

First post, not a big user of forums so please excuse any issues.

I'm having an issue with one of my functions in a C++ program. The complete error is:

C3867 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::assign': non-standard syntax; use '&' to create a pointer to member 87

The code for the function with the error is:

1
2
3
4
5
6
7
8
9
10
11
12
void Tools::CheckResult(const string Result, const string Key)
{
	vector<string> strScore(cResult.assign);
	strScore.push_back(",");
	strScore.push_back(Key);
	strScore.push_back(",");
	strScore.push_back(cResult);
	string Res;
	Res = accumulate(begin(strScore), end(strScore), Res);
	Results = Res;
	BubbleSort(Results);
};


The function BubbleSort called at the bottom. It has errors but they appear to be seperate from this issue. Solve that issue too if you are feeling really nice. :)

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
26
27
28
29
void Tools::BubbleSort(string arr)
{

	int temp;
	bool switchv = true;

	while (switchv)
	{
		switchv = false;
		for (int x = 0; x <= sizeof(arr) - 2; x++)
		{
			char A = arr[x];
			vector<char> arrA(A);
			arrA.push_back('.');
			int intA = Char::ToInt32(arrA[0]);
			char B = arr[x + 1];
			vector<char> arrB(B);
			arrB.push_back(',');
			int intB = int(arrB(B));
			if (int(intA) > int(intB))
			{
				temp = arr[x];
				arr[x] = arr[x + 1];
				arr[x + 1] = temp;
				switchv = true;
			}
		}
	}
};
Last edited on
What are you trying to do here? vector<string> strScore(cResult.assign);
Great question!

I'm putting the string cResult inti vector strScore so I can then add to strScore with .push_back later.

The overall point is to call BubbleSort with the final string of Results.

I'm happy to explain both functions but don't want to get long winded and bore people.
Any one of these:

1
2
// create a vector initially containing one string, a copy of cResult
std::vector<std::string> strScore( 1, cResult ) ; 


1
2
3
// create a vector initially containing copies of the strings in
// the initialiser list; ie. one string, a copy of cResult
std::vector<std::string> strScore{ cResult } ;


1
2
std::vector<std::string> strScore ; // create an empty vecor
strScore.push_back(cResult) ; // add a copy of cResult to it 
Thanks JL. That's perfect!
Topic archived. No new replies allowed.