0

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!

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by kunkunlol
1

Change line 4 to:

string str = "ABCD";
P1.Inverte(str);

Edited by jonsca: n/a

Votes + Comments
Saved my day rofl
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.