[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

Create a string class as shown below

ahdz10

10/24/2008 2:49:00 PM

class string
{ private:
.....
public:

//Constructor
//overloading constructor

//Destructor
friend function for accepting input
friend fuction for display output

}

a constructor which will initialize the string as the first line and
size with corresponding string length.


Another overloading constructor which will accept a string and
initialize it and its length to the class

Write a friend function which will read a string for the objext from
the keyboard
7 Answers

Obnoxious User

10/24/2008 2:56:00 PM

0

On Fri, 24 Oct 2008 07:49:21 -0700, ahdz10 wrote:

> class string
> { private:
> ....
> public:
>
> //Constructor
> //overloading constructor
>
> //Destructor
> friend function for accepting input
> friend fuction for display output
>
> }
>
> a constructor which will initialize the string as the first line and
> size with corresponding string length.
>
>
> Another overloading constructor which will accept a string and
> initialize it and its length to the class
>
> Write a friend function which will read a string for the objext from the
> keyboard

Have you tried writing it yourself?

--
OU
Remember 18th of June 2008, Democracy died that afternoon.
http://frapedia.se/wiki/Information_...

ahdz10

10/24/2008 3:00:00 PM

0

On Oct 24, 9:56 am, Obnoxious User <O...@127.0.0.1> wrote:
> On Fri, 24 Oct 2008 07:49:21 -0700, ahdz10 wrote:
> > class string
> > { private:
> > ....
> >  public:
>
> >       //Constructor
> >      //overloading constructor
>
> >      //Destructor
> > friend function for accepting input
> > friend fuction for display output
>
> > }
>
> > a constructor which will initialize the string as the first line and
> > size with corresponding string length.
>
> > Another overloading constructor which will accept a string and
> > initialize it and its length to the class
>
> > Write a friend function which will read a string for the objext from the
> > keyboard
>
> Have you tried writing it yourself?
>
> --
> OU
> Remember 18th of June 2008, Democracy died that afternoon.http://frapedia..se/wiki/Information_in_English- Hide quoted text -
>
> - Show quoted text -

I dont even know how to start =(

Obnoxious User

10/24/2008 3:18:00 PM

0

On Fri, 24 Oct 2008 08:00:01 -0700, ahdz10 wrote:

> On Oct 24, 9:56 am, Obnoxious User <O...@127.0.0.1> wrote:
>> On Fri, 24 Oct 2008 07:49:21 -0700, ahdz10 wrote:
>> > class string
>> > { private:
>> > ....
>> >  public:
>>
>> >       //Constructor
>> >      //overloading constructor
>>
>> >      //Destructor
>> > friend function for accepting input
>> > friend fuction for display output
>>
>> > }
>>
>> > a constructor which will initialize the string as the first line and
>> > size with corresponding string length.
>>
>> > Another overloading constructor which will accept a string and
>> > initialize it and its length to the class
>>
>> > Write a friend function which will read a string for the objext from
>> > the keyboard
>>
>> Have you tried writing it yourself?
>>
>
> I dont even know how to start =(

http://www.cplusplus.com/doc/tutorial/cl...

--
OU
Remember 18th of June 2008, Democracy died that afternoon.
http://frapedia.se/wiki/Information_...

ahdz10

10/24/2008 3:30:00 PM

0

thank you =)

osmium

10/24/2008 3:57:00 PM

0

<ahdz10@yahoo.com> wrote:

> class string
> { private:
> ....
> public:
>
> //Constructor
> //overloading constructor
>
> //Destructor
> friend function for accepting input
> friend fuction for display output
>
> }
>
> a constructor which will initialize the string as the first line and
> size with corresponding string length.
>
>
> Another overloading constructor which will accept a string and
> initialize it and its length to the class
>
> Write a friend function which will read a string for the objext from
> the keyboard

I hope that makes a lot more sense in the language in which you are
communicating with your instructor. In English as presented here it has all
kinds of problems in interpretation.

Start by making a wild guess that a string is a collection of characters of
*any* variety and the minimal data are a datum and a size. Figure out a
way to put some data in the two data members. Realize that you will have
no way to figure out whether what you write is correct and actually works.


red floyd

10/24/2008 10:00:00 PM

0

On Oct 24, 8:00 am, ahd...@yahoo.com wrote:
> On Oct 24, 9:56 am, Obnoxious User <O...@127.0.0.1> wrote:
> > On Fri, 24 Oct 2008 07:49:21 -0700, ahdz10 wrote:
> > >[blatant do my homework redacted]
> >
> > Have you tried writing it yourself?
>
> I dont even know how to start =(

Then talk to your instructor. But don't ask *us* to do your homework.

.rhavin grobert

10/27/2008 3:57:00 PM

0

On 24 Okt., 15:49, ahd...@yahoo.com wrote:
> class string
> { private:
> ....
>  public:
>
>       //Constructor
>      //overloading constructor
>
>      //Destructor
> friend function for accepting input
> friend fuction for display output
>
> }
>
> a constructor which will initialize the string as the first line and
> size with corresponding string length.
>
> Another overloading constructor which will accept a string and
> initialize it and its length to the class
>
> Write a friend function which will read a string for the objext from
> the keyboard

just a hint to let you start:



class string
{
private:

// the lenght of the string
unsigned int m_nLenght;

// the pointer to the allocated data
void* m_pData;

public:

// Constructor
string()
: m_pData(NULL), m_nLenght(0) {};

// copy constructor
string(string const& string s)
: m_nLenght(s.m_nLenght)
{
if (m_nLenght)
{
m_pData = NULL;
return;
}
m_pData = malloc(m_nLenght);
::memcpy(m_pData, s.m_pData, m_nLenght);
};

// Destructor
~string() {free(m_pData);};
};