473,405 Members | 2,415 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,405 software developers and data experts.

Create a string class as shown below

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
Oct 24 '08 #1
7 1707
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
Oct 24 '08 #2
On Oct 24, 9:56*am, Obnoxious User <O...@127.0.0.1wrote:
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 =(
Oct 24 '08 #3
On Fri, 24 Oct 2008 08:00:01 -0700, ahdz10 wrote:
On Oct 24, 9:56Â*am, Obnoxious User <O...@127.0.0.1wrote:
>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/classes.html

--
OU
Remember 18th of June 2008, Democracy died that afternoon.
http://frapedia.se/wiki/Information_in_English
Oct 24 '08 #4
thank you =)
Oct 24 '08 #5
<ah****@yahoo.comwrote:
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.
Oct 24 '08 #6
On Oct 24, 8:00*am, ahd...@yahoo.com wrote:
On Oct 24, 9:56*am, Obnoxious User <O...@127.0.0.1wrote:
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.
Oct 24 '08 #7
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);};
};

Oct 27 '08 #8

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

Similar topics

9
by: Divick | last post by:
Hi all, I have a problem related to std::string class. Is it ok to assign a global string variable to a local string object as shown below? I am trying to print the address of local string...
0
by: Kristian Frost | last post by:
Hi, I'm just getting started with VB.Net, and I'm having trouble getting the routing around of some of the data straight in my mind, which has led me to the following problem. Basically, I'm...
11
by: RipperT | last post by:
Don't know if this group covers web apps, but here goes. In VS 2005, I am trying to get variables to hold thier values during postback from the server. I convert a text box's user-keyed value to an...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
13
by: Bill Nguyen | last post by:
Is it possible to create your won XSD to use with .NET based on an XML content? For example the one below: <?xml version="1.0"?> <pcats:FuelsDoc...
10
by: Wilson | last post by:
i have created a class which contains all the information needed for a program based on accounts, this is shown below. When compiled the string "word" (in function writetofile) which is initialised...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
6
by: Patient Guy | last post by:
I am a newcomer to using PHP but not to programming (C, C++, Javascript). I am playing around with classes and wanted to make a function that has a method simply for producing either plain text...
3
by: David K in San Jose | last post by:
I'm using managed (CLR) C++ in VS2005 to create a Windows app that contains a form named "MyForm". In the code for that form I'm trying to invoke some static functions by using an array of function...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.