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...
-
Determine the energy destruction associated with each of the processes of the Rankine cycle described in Prob.1016, assuming a source temperature of 1500 K and a sink temperature of 290 K.
-
Home whitegoods manufacturer, Fresh Ltd, is evaluating the purchase of a new machine that will cost \($580\) 000 and be paid for in cash. The machine will be depreciated over 10 years with a resale...
-
Figure out how to profitably consummate the unconsummated wealth-creating transaction created by rent control.
-
How have advancements in membrane technology impacted extraction processes? Explore the use of membrane-based methods like pervaporation and membrane distillation in the extraction and purification...
-
Sally Saia operates Double S Riding Academy, Inc. The academys primary sources of revenue are riding fees and lesson fees, which are provided on a cash basis. Sally also boards horses for owners, who...
-
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 =...
-
Identify and define each of the three categories of advertising based on their purpose. Which type of advertising might marketers use for the following products? a. cars b. virtual reality headset c....
-
Do you agree or disagree with the framework previously built upon Meta-Leadership effectiveness and the response to COVID-19 based on cyber technology and distribution of the information from 2020?...
-
Did the Decision Tech Team go through all four stages of team development? If yes, discuss the effectiveness of Kathryn s approach to helping the team move through each stage. Give specific examples...
-
Various tools are available for developing and managing an auditing project plan and associated elements of an audit. Which tool is designed to enable an auditor to track audit deficiencies and areas...
-
The main problem of this study is what is the effect of the lecturer's perception of the practice of orientation multidimensional leadership by the head of the academic department on the...
-
Pick a company and analyze their EXTERNAL RISK MESSAGING in the enterprise risk management (ERM) process cycle. Company: What was the risk message? What risk did the organization identify in the...
-
Given n + 1 symbols x1, x2, . . . , xn, xn+1 appearing 1, f1, f2, . . . , fn times in a symbol string, respectively, where fj is the j th Fibonacci number, what is the maximum number of bits used to...
-
A survey of 70 college freshmen asked whether students planned to take biology, chemistry, or physics during their first year. Use the diagram to answer each question. How many of the surveyed...
-
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....
-
A 7 5 kg cliff - diver is falls from a height through the air head, diving towards the water. The drag coefficient for the diver is 0 . 8 3 and the area of the descending diver is 0 . 2 1 m ^ 2 ....
-
In the automobile industry, the dimensionless drag coefficient and the area of the vehicle are often combined into one variable - the drag area whereby the drag area is the product of the...
-
When you drop 10 pebbles into the well, you record the times for hearing the splash as 2.94 s, 3.11 s, 3.12 s, 2.97 s, 3.12 s, 2.97 s, 3.06 s, 3.21 s, 3.37 s, and 3.53 s. (a) Find the average time...
Study smarter with the SolutionInn App