473,387 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

can sombody tel this constructor problem.

aki
#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
Jul 22 '08 #1
2 1129
aki wrote:
#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
Jul 22 '08 #2
xyz
On Jul 22, 3:50*pm, aki <akhileshrawat...@gmail.comwrote:
#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;
}
Jul 22 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Amadrias | last post by:
Hi all, I am using a class to transport some data over the network. I then added the attribute to the class. My problem is that this class is part of a framework and that I do not want...
6
by: Nafai | last post by:
Hello. I want to do something like this: class A { // It's virtual protected: float* data; int n; public: A(int a); virtual float* createData(); //...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
23
by: TarheelsFan | last post by:
What happens whenever you throw an exception from within a constructor? Does the object just not get instantiated? Thanks for replies.
74
by: Zytan | last post by:
I have a struct constructor to initialize all of my private (or public readonly) fields. There still exists the default constructor that sets them all to zero. Is there a way to remove the...
22
by: clicwar | last post by:
A simple program with operator overloading and copy constructor: #include <iostream> #include <string> using namespace std; class Vector { private: float x,y; public: Vector(float u, float...
1
by: hemant kamble | last post by:
Hi all, I am hemant , I am new for VB. Can sombody help to access serial port in VB on windows XP. I am trying with Ports.bas but ididn't get success kindly anybody give code for access serial...
13
by: JD | last post by:
Hi, My associate has written a copy constructor for a class. Now I need to add an operator = to the class. Is there a way to do it without change her code (copy constructor) at all? Your help...
0
by: hemant kamble | last post by:
Hi all, I am hemant , I am new for VB. Can sombody help to access serial port in VB on windows XP. I am trying with Ports.bas but ididn't get success kindly anybody give code for access serial...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.