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!

Change line 4 to:

string str = "ABCD";
P1.Inverte(str);
commented: Saved my day rofl +1

Thank You!

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.