I have a pair member data in a class: pair<double,double> memory;
How can I change the firs or second element?
If I simply write memory.first = 42 the compiler says read-only structure
If I use memory = pair<double,double>(42,42) than: error passing 'this' argument
I dont understand, please help me

Recommended Answers

All 2 Replies

duplicate post :(

can you post the function prototype/short segment of code?
Your first example should work, as I compiled the following:

pair<double, double> memory;
	memory.first = 23;
	memory.second = 2;

	cout << memory.first << endl;

however, its possible memory is a class variable and this is a const function, for example, which might cause your errors.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.