#include<iostream.h>
class rectangle
{
protected:

        int lenght,widht,height;


public:
        rectangle(){lenght=0;widht=0;height=0;};
        void seta(int lenghti);
        void setb(int widthi);
        void setc(int heighti);
        int getlenght();
        int getwidth();
        int getheight();
};
class box:protected rectangle
{
private:
      int length,width,height;
    public:
        rectangle(){length=0;width=0;height=0;};
        void setlenght(int lenght);
        void setwidth(int width);
        void setheight(int height);
        int getlenght();
        int getwidht();
        int getArea();
        int getPerimeter();
        int getVolume();
};

#include<iostream.h>
#include"rectangle.h"

void main()

{
    box mybox;
    int lenght,widht,height;
    cout<<"enter lenght";
    cin>>lenght;
    cout<<"enter width";
    cin>>width;
    cout<<"enter height";
    cin>>height;
    int a,b,c,;
    cout<<"enter lenght";cin>>lenght;
    cout<<"enter width";cin>>widht;
    cout<<"enter height";cin>>height;
    mybox.setlenght(lenght);
    mybox.setwidth(width);
    mybox.setheight(height);
    cout<<"Area is"<<mybox.getArea()endl;
    cout<<"Parameter is"<<mybox.getparameter()endl;
    cout<<"volume is"<<mybox.getvolume()endl;

#include<iostream.h>
#include"rectangle.h"
#include"mybox.cpp"
void box::seta,b,c,(int a,int b,int c,);
{
    lenght=a;
    widht=b;
    height=c;
}
{
int box::geta();
 return a;
 }
{
int box::getb();
 return b;
}
 }
 int box::getc();
 return c;
 }
{
    int box::getarea()
 return a*b;
  }
{
 int box::getparameter()
     return a+b;
 }
{
 int box::getVolume()
     return a*b*c;
 }

Edited 3 Years Ago by Dani: Formatting fixed

hi,

first at all <iostream.h> is out of date from 1999 years is only <iostream>.

and please post your code in CODE section (bbcode).

Put your code in [code][/code] tags.

class box:Protected rectangle

->

class box : protected rectangle

All C++ keywords are in lowercase.

void main()

It's int main().

#include"mybox.cpp"

You shouldn't include .cpp files. Use a project instead.

void box::seta,b,c,(int a,int b,int c,);
{
lenght=a;
widht=b;
height=c;
}

You have an extra comma and an extra semicolon as well. Remove both of them.

{
int box::getVolume()
return a*b*c;
}

->

int box::getVolume()
{
return a*b*c;
}

etc . . . .

Edited 3 Years Ago by Dani: Formatting fixed

class box:Protected rectangle
{
private:
int length,width,height;
public:
rectangle(){length=0;width=0;height=0;};
  1. As mentioned, Protected is lowercase.
  2. This isn't in the rectangle class, so you don't use the rectangle constructor.
  3. You have an extra semicolon at the end of your constructor (it's not an error, but it isn't required, either).

And work on your indentation . . . or just code tags.

This article has been dead for over six months. Start a new discussion instead.