check for errors in my code

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2006
Posts: 5
Reputation: brianotieno is an unknown quantity at this point 
Solved Threads: 0
brianotieno brianotieno is offline Offline
Newbie Poster

check for errors in my code

 
0
  #1
Feb 24th, 2006
#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;
}
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,401
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1467
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: check for errors in my code

 
0
  #2
Feb 24th, 2006
what errors does your compiler produce? post the first few error messages.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 9
Reputation: ludesign is an unknown quantity at this point 
Solved Threads: 0
ludesign's Avatar
ludesign ludesign is offline Offline
Newbie Poster

Re: check for errors in my code

 
0
  #3
Feb 24th, 2006
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).
Винаги Ñ?е цели в луната, така и да пропуÑ?неш, пак ще Ñ?и Ñ?ред звездите!
by ludesign
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 251
Reputation: dwks has a spectacular aura about dwks has a spectacular aura about 
Solved Threads: 25
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: check for errors in my code

 
0
  #4
Feb 28th, 2006
Put your code in [code] [/code] tags.
  1. class box:Protected rectangle
->
  1. class box : protected rectangle
All C++ keywords are in lowercase.

  1. void main()
It's int main().

  1. #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.
  1. {
  2. int box::getVolume()
  3. return a*b*c;
  4. }
->
  1. int box::getVolume()
  2. {
  3. return a*b*c;
  4. }
etc . . . .
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 251
Reputation: dwks has a spectacular aura about dwks has a spectacular aura about 
Solved Threads: 25
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: check for errors in my code

 
0
  #5
Feb 28th, 2006
  1. class box:Protected rectangle
  2. {
  3. private:
  4. int length,width,height;
  5. public:
  6. 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.
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC