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
Aleonysh [2.5K]
3 years ago
7

Write a C++ Programm in which inheritance is used

Computers and Technology
1 answer:
geniusboy [140]3 years ago
8 0

Answer:

// C++ program to demonstrate inheritance

#include <iostream>

using namespace std;

// base class

class Animal {

  public:

   void eat() {

       cout << "I can eat!" << endl;

   }

   void sleep() {

       cout << "I can sleep!" << endl;

   }

};

// derived class

class Dog : public Animal {

  public:

   void bark() {

       cout << "I can bark! Woof woof!!" << endl;

   }

};

int main() {

   // Create object of the Dog class

   Dog dog1;

   // Calling members of the base class

   dog1.eat();

   dog1.sleep();

   // Calling member of the derived class

   dog1.bark();

   return 0;

}

You might be interested in
How can I make a video game?
Rainbow [258]
You first need to figure out what kind of game you would like to create. Find codes and certain websites that will help you set up and or make a game.
3 0
3 years ago
Read 2 more answers
Can you answer this question?
patriot [66]

Answer:

To do this you'll need to use malloc to assign memory to the pointers used.  You'll also need to use free to unassign that memory at the end of the program using the free.  Both of these are in stdlib.h.

#include <stdlib.h>

#include <stdio.h>

#define SIZE_X 3

#define SIZE_Y 4

int main(void){

       int **matrix, i, j;

       // allocate the memory

       matrix = (int**)malloc(SIZE_X * sizeof(int*));

       for(i = 0; i < SIZE_X; i++){

               matrix[i] = (int *)malloc(SIZE_Y * sizeof(int));

       }

       // assign the values

       for(i = 0; i < SIZE_X; i++){

               for(j = 0; j < SIZE_Y; j++){

                       matrix[i][j] = SIZE_Y * i + j + 1;

               }

       }

       // print it out

       for(i = 0; i < SIZE_X; i++){

               for(j = 0; j < SIZE_X; j++){

                       printf("%d, %d:  %d\n", i, j, matrix[i][j]);

               }

       }

       // free the memory

       for(i = 0; i < SIZE_X; i++){

               free(matrix[i]);

       }

       free(matrix);

       return 0;

}

3 0
3 years ago
write an algorithm that gets two values: the price for item A and the quantity purchased. The algorithm should then print the to
pochemuha

Answer:

Explanation:

price = eval(input("price of item: "))

quantity = eval(input("quantity of item: "))

sales_tax = 0.08 # 8% sales tax

total_cost = price*quantity

total_cost_with_tax = total_cost + total_cost*sales_tax

print("total cost: "+str(total_cost))

print("total cost + 8% sales tax: "+str(total_cost_with_tax))

5 0
4 years ago
Samantha plans an investigation in which she will study a population of animals. Which of these answers best describes the focus
Y_Kistochka [10]
The cats and dogs at a local shelter. Because there is so many in shelters
4 0
4 years ago
Assuming each reference costs 1 byte, and each piece of data/info costs 1 byte as well. When will a doubly linked list be more a
NeX [460]

Answer:

The circular individually linked list is more efficient for time sharing process ,when multiple application are running on pc it is responsibility of an output system to put all process on a list and execute them all by giving them piece of time and make them wait when cpu is selected to other process.

It will be more suitable for output system to use circular list as when it reaches to last of list it will be manually reaches to starting node or process.

Singly circular linked list is used when we are concerned with the memory as only one process will be allocated memory at once and there are no chances of process to go never-ending waiting.

Explanation:

8 0
4 years ago
Other questions:
  • Which type of multiplexing divides transmission opportunities into slots of 125 microseconds with position inside each slot rese
    10·1 answer
  • As a trainer for Exempla Healthcare, Tina is faced with many challenges to properly training her new hires. There are over 40 di
    15·1 answer
  • Please help on this project, I'm not sure why but I've had lots of trouble with it. I'll try my best to show the instructions fo
    12·1 answer
  • In which of the following situations will a macro make your work more efficient?
    7·1 answer
  • Outline the things that Mccann needs to do right away
    13·1 answer
  • Why are various creative works split up into different types under copyright law?
    9·1 answer
  • Copyright ownership analysis starts with this principle: The ________ is the owner.
    6·1 answer
  • write a program that inputs 3 numbers and prints the largest input must be transformed into a integer but printed as a string​
    11·1 answer
  • Overview In this assignment, you will gain more practice with designing a program. Specifically, you will create pseudocode for
    7·1 answer
  • PLZZZZ HELPPP and please don’t send a link , Explain how the processing stage contributes to a computer creating an output.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!