1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sladkaya [172]
3 years ago
15

Create a class Str that subclasses str. Add a method to the subclass that checks if the string does not start with a given strin

g. Call that method notstartswith
Computers and Technology
1 answer:
Stolb23 [73]3 years ago
3 0

Answer:

#include <iostream>

using namespace std;

class Str{  ///baseclass

   public :

   string super_str;

   string getStr()

   {

       return super_str;

   }

   void setStr(string String)

   {

       super_str=String;

   }

};

class str : public Str{   //inheriting Str publicly

   public :

       string sub_str;

       string getstr()

       {

           return sub_str;

       }

       void setstr(string String)

       {

           sub_str=String;

       }

       bool notstartswith()

       {

           int n=sub_str.length();   //to find length of substr

           bool flag=false;

           for(int i=0;i<n;i++)     //Loop to check beginning of Str

           {

               if(super_str[i]!=sub_str[i])

               {

                   flag=true;

                   break;

               }

           }

           return flag;

       }

};

int main()

{

   str s;    //object of subclass

   s.setStr("Helloworld");  

   s.setstr("Hey");

   if(s.notstartswith()==1)     //checking if str is substring of Str

       cout<<"Str does not start with str";

   else

       cout<<"Str starts with str";

   return 0;

}

OUTPUT :

Str does not start with str

Explanation:

Above program is implemented the way as mentioned. for loop is being used to check the beginning of the str starts with substring or not.

You might be interested in
Please answer the following essay question:
MArishka [77]
Advertising is a paid promotion that uses strategic planning to target a certain audience. The seven functions of marketing is promotion, selling, product management, marketing information management, pricing, financing, and distribution. Usually you see common advertising such as digital ads, billboards, newspapers, flyers, and more. Advertising can spread awareness, popularize a brand, increase customer demand, and company profits. Advertising is necessary for most- if not all- companies including media outlets, the television industry, search engine companies, and social media websites.
8 0
3 years ago
Does anyone know how to change your username? plz help I don't want my name on this lmo
Eduardwww [97]
I do. Try deleting the app and reinstall it but you will lose all your score.
3 0
3 years ago
Read 2 more answers
Using the flowchart below, what value when entered for Y will generate a mathematical error and prevent our flowchart from being
nexus9112 [7]

Answer:

The answer is the last choice that is "None of these values will produce a mathematical error".

Explanation:

In this question, the above given choice correct because neither of the flowchart procedures could trigger a mathematical error. This error could not be induced by multiplication, addition and subtraction, and the only division by 15. It is the only divide by 0, that's why the above flowchart will produce a mathematical error.

4 0
3 years ago
Which element of a presentation program’s interface displays the slide you are currently creating or editing?
irinina [24]

I believe the answer is: Slide Plane

5 0
3 years ago
Read 2 more answers
Ann wants to download Adobe Acrobat software from the Internet. Prior to downloading, a standardized online contract appears on
IceJOKER [234]
Answer: terms and services
5 0
3 years ago
Other questions:
  • The utilization of a subset of the performance equation as a performance metric is a pitfall. To illustrate this, assume the fol
    13·1 answer
  • What are the advantages of repeating a header row? check all that apply
    14·1 answer
  • Web crawlers or spiders collect information from Web pages in an automated or semi-automated way. Only the text of Web pages is
    10·1 answer
  • Write a function so that the main program below can be replaced by the simpler code that calls function mph_and_minutes_to_miles
    7·1 answer
  • How do you know where the home row of the keyboard is?
    14·2 answers
  • What do Business Analysis workers do? Check all that apply.
    15·2 answers
  • Choose the type of error described.
    12·1 answer
  • Create an application that determines the final cost of food items and non-food items, assuming only non-food items are taxed. T
    8·1 answer
  • Most effective way of closing email is<br>​
    7·2 answers
  • Create a timeline of the evolution of computers and their impact on society
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!