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...
-
Why do many small businesses fail when a big discount retailer such as Wal-Mart enters their market?
-
how researchers examined the effectiveness of members of the U.S. Congress
-
Prepare a Gantt chart for each of the following in the style of the chart shown on p. 739. a. The bank location problem (Figure). b. Solved Problem number 2 on pp. 766768. Activity-on-arroww (AOA)...
-
Sarasota Design Works generated $533,520 in operating income on sales revenue of $2,964,000. The company had $2,370,000 in assets on January 1 and $2.830,000 in assets on December 31. (a-b) (a)...
-
You plan to save $7,500 at the end of each year for three years. Your bank account pays 5% of interest per year. At the end of the fourth year, you will deposit $10,000 in this account. How much...
-
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 =...
-
What is the effect on a partnership of a proportionate liquidating distribution of cash, appreciated land, and inventory where the partnership also liquidates? How does this compare to a liquidating...
-
Question TARIMAX MASTO Copper Explorations recently acquired the rights to mine a new site. Machinery, equipment and a truck were purchased to begin the mining operations at the site. Details of the...
-
Exercise 6 - 6 ( Algo ) The Town of Weston has a Water Utility Fund with the following trial balance as of July 1 , 2 0 2 3 , the first day of the fiscal year: During the year ended June 3 0 , 2 0 2...
-
The University of Cincinnati Center for Business Analytics is an outreach center that collaborates with industry partners on applied research and continuing education in business analytics. One of...
-
What is the correct answer to this? SQL QUESTION Sales Data for All Customers and Products Write a query that will return sales details of all customers and products. The query should return all...
-
Below are the jersey numbers of 11 players randomly selected from a football team. Find the range, variance, and standard deviation for the given sample data. What do the results tell us? 84 18 34 3...
-
For (x) = 3x and g(x) = [1/4] x , find each of the following. Round answers to the nearest thousandth as needed. g(-1.68)
-
Find a polar equation for the curve represented by the given Cartesian equation. 4y 2 = x
-
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....
-
On NSE (Indian stock exchange), shares of ICICI Bank trade for 935 rupees. If the spot exchange rate is USD 0.012, what is the no-arbitrage USD price of ICICI Bank ADR? Assume that transactions costs...
-
Income Statement Balance Sheet Balance Sheet Additional Financial Information 1. Market price of Ranfield's common stock: $90.44 at December 31, 2024, and $58.35 at December 31, 2023. 2. Common...
-
There is a credit rating agency for businesses that gives out various amounts of information based on the subscription level. This company is called a. Business Credit Scoring b. Fair Issue c. Dun...
Study smarter with the SolutionInn App