Hi, I'm doing some stuff about stacks (classes).


I've done a function, wich will invert the string, however, the VC++ gives a dumb error and I don't know why.

I have alot of libs so, i think it's not because of that. Anyway heres the error:
'CPilhaInteiros::Inverte' : cannot convert parameter 1 from 'const char [5]' to 'std::string &'

Well I leave the code here:

int main(){
  CPilhaInteiros P1;
  
  P1.Inverte("ABCD")

  return 0;

}
void CPilhaInteiros::Inverte(string &s){
	CPilhaInteiros temp;
	int aux,str_len;

	str_len=s.length();
	for(int i=0;i<str_len;i++){
		temp.Push(s[i]);
	}

	for(int i=0;i<str_len;i++){
		temp.Pop(aux);
		s+=(char)aux;
	
	}

}

Thanks!

Recommended Answers

Change line 4 to:
[code]
string str = "ABCD";
P1.Inverte(str);
[/code]

Jump to Post

All 2 Replies

Change line 4 to:

string str = "ABCD";
P1.Inverte(str);
commented: Saved my day rofl +1
Be a part of the DaniWeb community

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