Connecting Tech Pros Worldwide Forums | Help | Site Map

can sombody tel this constructor problem.

aki
Guest
 
Posts: n/a
#1: Jul 22 '08
#include<iostream>
using namespace std;
class string
{
char *str;
public:
string(char *st)
{
str=st;

};
~string();
void reversestr(char *str);
//void showstr();
};

int main ()
{
string s("akhilesh");




Thanks
Aki

Victor Bazarov
Guest
 
Posts: n/a
#2: Jul 22 '08

re: can sombody tel this constructor problem.


aki wrote:
Quote:
#include<iostream>
using namespace std;
class string
{
char *str;
public:
string(char *st)
{
str=st;
>
};
~string();
void reversestr(char *str);
//void showstr();
};
>
int main ()
{
string s("akhilesh");
>
Aside from (a) a missing closing curly brace at the end of 'main' and
(b) the fact that the name of your class is the same as the standard
class 'string', what exactly is the problem?

Also, consider asking your question in the text of the posting instead
of the subject line.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
xyz
Guest
 
Posts: n/a
#3: Jul 22 '08

re: can sombody tel this constructor problem.


On Jul 22, 3:50*pm, aki <akhileshrawat...@gmail.comwrote:
Quote:
#include<iostream>
using namespace std;
class string
* * *{
* * * char *str;
* * * public:
* * * string(char *st)
* * * {
* * * *str=st;
>
* * * };
* * * ~string();
* * * void reversestr(char *str);
* * * //void showstr();
* * *};
>
int main ()
{
* *string s("akhilesh");
>
Thanks
Aki
problem with the function name...change from string to other

#include<iostream>
using namespace std;
class string1
{
public:
string1(char *st){ str=st;cout<<"**str:"<<st<<endl ;}
private:
char *str;
};

int main ()
{
string1 s("akhilesh");
return 0;
}
Closed Thread