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
A type of touch screen that can be up to four feet by six feet is a(n) _____.
Llana [10]
Hi,

A type of touch screen that can be up to four feet by six feet is a(n) <span>multitouch interface.
</span>.
7 0
3 years ago
Read 2 more answers
science and technology are interdependent advances in one lead to advances in the other. give an example of this phenomenon.
goblinko [34]
Wouldn't it Be Stem ? 
Science 
technology
Engineering 
Mathmatics 
5 0
3 years ago
Which of the following is an example of data an Earth-observing satellite would collect?
Natalka [10]

Answer:

A

Explanation:

Hopefully this helps

4 0
2 years ago
The function known as "Comments" can be displayed during a presentation<br>O True<br>False​
Sonja [21]

Answer:

false

Explanation:

Select the comment icon. on the slide. The Comments pane will open and you can see comments for that slide.

Select Reply to respond to a comment.

Select the Next or Back buttons to go between comments and slides.

3 0
3 years ago
Read 2 more answers
In which of selye's stages in death a possible outcome?
kkurt [141]
D)Exhaustion
Hope this helps
6 0
3 years ago
Other questions:
  • 1).
    12·1 answer
  • Write a function, factors, that takes an integer n, and returns a list of values that are the positive divisors of n. Note: 0 is
    13·1 answer
  • Naseer has inserted an image into his document but needs the image to appear on its own line.
    14·2 answers
  • Find the 65th percentile from the data. The data consist of class interval from 0-10, 10-20, 20-30, 30-40, 40-50, 50-60 and freq
    8·1 answer
  • What is the printout of the call nPrint("a", 4)?
    14·1 answer
  • You are having problems on your Windows 7 computer and you pull up Device Manager to see if there are any alerts. Two of your de
    11·1 answer
  • It is important to name your files in a variety of formats. true or false
    15·2 answers
  • If 209g of ethanol are used up in a combustion process, calculator the volume of oxygen used for the combustion at stp​
    5·1 answer
  • Temperature converter. This program should prompt the user for two arguments, first a decimal number and second, a single letter
    10·1 answer
  • These brainly bots need to stop!!
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!