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]
4 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]4 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 measure of the processing power of a computer
IgorLugansk [536]
<h2>Million instructions per second (MIPS)</h2>

Explanation:

Real-life example of measurement:

Like how we measures vegetables & fruits in Kilograms, how we measure water or other liquids in liters, we measure the processing power of a computer with the help of unit called MIPS.

What is processing power?

The number of instruction that a computer can process in one second helps us to calculate the "speed of the computer".

This can also be termed as measuring the clock speed. Its measured in Giga hertz or mega hertz.

Why this is necessary?

  • It is to pick the best system to buy. (Also considering the need an budget)
  • Purchasing system based on the requirement.

6 0
3 years ago
What does HTML stand for?
Wittaler [7]

Hypertext Markup Language

5 0
3 years ago
Read 2 more answers
The ____ is a new feature in versions of microsoft office, starting with office 2007; it consists of tabs, which contain groups
lions [1.4K]
Excel i think that's correct
5 0
3 years ago
Bill, a project manager, wants to hire external resources. What step should Bill take before hiring external resources?
solniwko [45]
The answer to this is verify the resources identified by experts 
7 0
3 years ago
Which invention allowed computers to become smaller in size?
dexar [7]
computers got smaller because one of its main components the valve – was replaced by the much smaller transistor.
7 0
3 years ago
Other questions:
  • To join two or more objects to make a larger whole is to _____________ them.
    11·2 answers
  • Windows 7 is used to run ____ software
    5·2 answers
  • Most OEMs recommend that the engine oil be replaced and a new filter installed at which of the following mileage intervals ?
    7·1 answer
  • Which of the following is not a method of data management?
    15·1 answer
  • Is phone data used when connected to wifi
    12·1 answer
  • [BRAINLIEST!!!! Which concept in OOP explains the relationship between the classes Nation and President, where the class Nation
    6·2 answers
  • How do you detect my account for brainly?
    14·1 answer
  • How to hack a I'd Indian brainly bot​
    7·1 answer
  • Directions: Give the shortcut key for the following commands: 1. Open 2. Save 3. New document 4. Copy 5. Undo 6. Redo 7. Paste 8
    5·1 answer
  • Which communication technology often takes the place of printed interoffice communication?.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!