| | |
check for errors in my code
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2006
Posts: 5
Reputation:
Solved Threads: 0
#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;
}
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;
}
Put your code in [code] [/code] tags.
->
All C++ keywords are in lowercase.
It's int main().
You shouldn't include .cpp files. Use a project instead.
You have an extra comma and an extra semicolon as well. Remove both of them.
->
etc . . . .
C++ Syntax (Toggle Plain Text)
class box:Protected rectangle
C++ Syntax (Toggle Plain Text)
class box : protected rectangle
C++ Syntax (Toggle Plain Text)
void main()
C++ Syntax (Toggle Plain Text)
#include"mybox.cpp"
void box::seta,b,c,(int a,int b,int c,); { lenght=a; widht=b; height=c; }
C++ Syntax (Toggle Plain Text)
{ int box::getVolume() return a*b*c; }
C++ Syntax (Toggle Plain Text)
int box::getVolume() { return a*b*c; }
dwk
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
C++ Syntax (Toggle Plain Text)
class box:Protected rectangle { private: int length,width,height; public: rectangle(){length=0;width=0;height=0;};
- As mentioned, Protected is lowercase.
- This isn't in the rectangle class, so you don't use the rectangle constructor.
- 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.
dwk
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
![]() |
Similar Threads
- Error 993 Partition contains open files. Use the operating system check utility (Windows NT / 2000 / XP)
- syntax errors and the check module command? (Python)
- Monitor shuts off after check disk for errors (Windows NT / 2000 / XP)
- Spell Check Open Source Code Required (JSP)
- Please could you help me with my code :) (Assembly)
- Check the code!! (C++)
- Re: Check for Disk Errors in Windows XP (Windows NT / 2000 / XP)
- Check for Disk Errors in Windows XP (Windows tips 'n' tweaks)
Other Threads in the C++ Forum
- Previous Thread: Creating dynamic arrays
- Next Thread: Great what did I miss?
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code coding compile console conversion convert count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






