lohitverma
asked on
String literal converted to char* in formal argument
Hi
I have a small snipet of code that compiles fine in VC++ 6.0 but throws the warning
String literal converted to char* in formal argument , while compiling with Solaris 5.6, CC compiler.
Even though the run time results are correct, I would like to remove this warning
Any suggestions.
#include<iostream>
using namespace std;
class A
{
public:
void hi(string a){
cout<<"String "<<a.c_str()<<endl;
}
void hi(char* a){
cout<<"char* "<<a<<endl;
}
};
int main(int argc, char *argv[])
{
string a="HAHHAHAHAHH";
A b;
b.hi(a);
b.hi("HOHOHOHOHO");
return 1;
}
Thanks
Lohit
I have a small snipet of code that compiles fine in VC++ 6.0 but throws the warning
String literal converted to char* in formal argument , while compiling with Solaris 5.6, CC compiler.
Even though the run time results are correct, I would like to remove this warning
Any suggestions.
#include<iostream>
using namespace std;
class A
{
public:
void hi(string a){
cout<<"String "<<a.c_str()<<endl;
}
void hi(char* a){
cout<<"char* "<<a<<endl;
}
};
int main(int argc, char *argv[])
{
string a="HAHHAHAHAHH";
A b;
b.hi(a);
b.hi("HOHOHOHOHO");
return 1;
}
Thanks
Lohit
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.