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
Formatting can be applied to
valkas [14]
Formatting can maybe be applied to software works
8 0
3 years ago
Read 2 more answers
Which of these sedimentary rocks is made of the largest particles?
Marta_Voda [28]
Your answer is <span>A.conglomerate.

Hope this helps :)</span>
6 0
3 years ago
What is Gpu in simple terms ​
Bingel [31]
Graphic processing unit !!?????!!??!??!?!!?!!?
5 0
2 years ago
Read 2 more answers
When creating a database, in which step do you add foreign keys to tables?
lana66690 [7]
Https://docs.microsoft.com/en-us/sql/relational-databases/tables/create-foreign-key-relationships 
8 0
3 years ago
After you select your recipients, the next step in using the Mail Merge Wizard would be to _____.
NARA [144]

Answer:

Write your letter

Explanation:

When using a Mail Merge Wizard in a Microsoft Word Document, this is the process.

  • Click on your document type
  • Click on the starting document
  • Select the recipient(s)
  • Write your letter and add some custom fields
  • Insert your address Block
  • Strike enter and click on Greeting line (to enter a greeting)
  • Preview your letter and click on complete merge
3 0
3 years ago
Read 2 more answers
Other questions:
  • Write an expression that executes the loop body as long as the user enters a non-negative number.Note: If the submitted code has
    11·1 answer
  • The following method public String removeFromString(String old, String frag) removes all occurences of the string frag from the
    12·1 answer
  • The most common type of local correction system is
    11·1 answer
  • To reboot a pc, hold down the ____ keys at the same time.
    15·1 answer
  • Excel assigns the name ____ to the first excel table created in a workbook.
    10·1 answer
  • All of the following are forms of verbal communication except
    12·2 answers
  • According to the video, what education and experience do employers look for in Reporters and Correspondents? Check all that appl
    10·2 answers
  • How do you use bold text?
    5·2 answers
  • What keyboard functions lets you delete words
    9·2 answers
  • How many pages is 1500 words double spaced 12 font?.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!