Suppose a String class has the following private members: class String { private: char * str; //
Question:
Suppose a String class has the following private members:
class String
{
private:
char * str; // points to string allocated by new
int len; // holds length of string
//...
};
a. What’s wrong with this default constructor?
String::String() {}
b. What’s wrong with this constructor?
String::String(const char * s)
{
str = s;
len = strlen(s);
}
c. What’s wrong with this constructor?
String::String(const char * s)
{
strcpy(str, s);
len = strlen(s);
}
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 70% (17 reviews)
a There is no problem with this default constructor but it might do a lot of work for an empt...View the full answer
Answered By
Brian Otieno
I'm Brian , an experienced professional freelancer with countless hours of success in freelancing many subjects in different disciplines. Specifically, I have handled many subjects and excelled in many disciplines. I have worked on many Computer Science projects and have been able to achieve a lot in that field. Additionally, I have handled other disciplines like History, Humanities, Social Sciences, Political science, Health care and life science, and Religion / Theology. My experience generally in these subjects has made me able to deliver high-quality projects in a very timely fashion. I am very reliable at my job and will get the work done in time, no matter what. In Addition, I have managed to ensure that the work meets my client's expectations and does not cause an error. I am a hard-working and diligent person who is highly responsible for everything I do. Generally, Freelancing has made me more accountable for doing my job. Additionally, I have had a passion for writing for the last seven years in this field.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
A light string with a mass per unit length of 8.00 g/m has its ends tied to two walls separated by a distance equal to three fourths of the length of the string (Fig. P16.30) An object of mass m is...
-
A steel guitar string has a tension F, length L, and diameter D. Give the multiplicative factor by which the fundamental frequency of the string changes under the following conditions: (a) The...
-
A string has a mass per unit length of 9.00 X 103 kg/m and a length of 0.400 m. What must be the tension in the string if its second harmonic has the same frequency as the second resonance mode of a...
-
Which one can be considered as the last stage in knowledge management system O A. Identifying O B. Disseminating O C. Capturing O D. Storing
-
You have borrowed $14,300 at a compound annual interest rate of 15 percent. You feel that you will be able to make annual payments of $3,000 per year on your loan. (Payments include both principal...
-
Expectant parents are thrilled to hear their unborn babys heartbeat, revealed by an ultrasonic motion detector. Suppose the fetuss ventricular wall moves in simple harmonic motion with amplitude of...
-
How to cure a default judgment?
-
(a) If $100 at Time "0" will be worth $110 a year hence and was $90 a year ago, compute the interest rate for the past year and the interest rate next year. (b) Assume that $90 invested a year ago...
-
A $ 1 , 0 0 0 face amount 8 % convertible bond has a conversion ratio of 2 0 . The firm s common stock is currently selling at $ 4 0 . If the bond is about to mature, what is its value?
-
Deanna Nardelli started her own consulting firm, Nardelli Consulting, on May 1, 2014. The trial balance at May 31 is as follows. In addition to those accounts listed on the trial balance, the chart...
-
Consider the following class declaration: class Cow { char name[20]; char * hobby; double weight; public: Cow(); Cow(const char * nm, const char * ho, double wt); Cow(const Cow c&); ~Cow(); Cow &...
-
A complex number has two parts: a real part and an imaginary part. One way to write an imaginary number is this: (3.0, 4.0). Here 3.0 is the real part and 4.0 is the imaginary part. Suppose a =...
-
As measured by an observer on the earth, a spacecraft runway on earth has a length of 3600 m. (a) What is the length of the runway as measured by a pilot of a spacecraft flying past at a speed of...
-
Define entrepreneurial philanthropy. Why is this topic likely to receive increased attention in the future?
-
Describe the ways in which entrepreneurship is perpetuated. Describe the role of serial entrepreneurs in this process.
-
In connection with their audit of the financial statements of Davis Company, the auditors reviewed the Federal Income Taxes Payable account. Required: a. Discuss reasons why the auditors should...
-
Describe the major components of entrepreneurial succession. What are the most difficult areas of succession? How do successions overlap over time?
-
Define entrepreneurial succession and differentiate between entrepreneurial succession in family and non-family firms.
-
Why may grinding operations be necessary for parts that have been machined by other processes?
-
A new car sold for $31,000. If the vehicle loses 15% of its value each year, how much will it be worth after 10 years?
-
Create a new class file called AndExericse with a main() container. Use && operator to create the following outputs: X P = true, Q = true. Therefore P && Q is true P = false, Q = true. Therefore. P...
-
Create a new class file called NotExercise with a main() container. Use ! operator to create the following outputs: X P is true. Therefore !P is false P is false. Therefore !P is true
-
Create a new class file called OrExercise with a main() container. Use the ( ) operator to create the following outputs: IX P is true and Q is true. Therefore, P | P is false and Q is true....
-
Explain by giving examples the causes of the differences between taxable income and accounting income ( 5 Marks ) b . Dolphin Company Limited has results of its operations for the year 2 0 1 4 as...
-
Navkar Corporation Limited showed the inventory stock on S ptember 3 0 , 2 0 1 7 , is R$ 7 5 , 0 0 0 . From September 1 5 to September 3 0 , the gross sales of the company were R$ 1 2 5 , 0 0 0 ;...
-
Discuss the process of creating a flexible budget. What are the key steps involved, and how does it differ from the process of developing a static budget?
Study smarter with the SolutionInn App