Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Create a string class as shown below

Reply
Thread Tools

Create a string class as shown below

 
 
ahdz10@yahoo.com
Guest
Posts: n/a
 
      10-24-2008
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
 
Reply With Quote
 
 
 
 
ahdz10@yahoo.com
Guest
Posts: n/a
 
      10-24-2008
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 =(
 
Reply With Quote
 
 
 
 
ahdz10@yahoo.com
Guest
Posts: n/a
 
      10-24-2008
thank you =)
 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      10-24-2008
<> 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.


 
Reply With Quote
 
red floyd
Guest
Posts: n/a
 
      10-24-2008
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.
 
Reply With Quote
 
.rhavin grobert
Guest
Posts: n/a
 
      10-27-2008
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);};
};

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Browser crashes with below code.What is wrong in below code. kiran Javascript 12 12-07-2011 02:38 PM
Could someone scan me a picture of the below? (Read Below) starlightvoyager@yahoo.com DVD Video 1 08-28-2006 05:42 AM
How to create the list shown in google suggest under the text box. Or Javascript 4 11-13-2005 11:11 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
NOT SHOWN. The page is not shown until refresh it ! Mete Akalın ASP General 1 07-25-2003 11:28 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57