GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Apr-2004, 18:21
Mjkramer21's Avatar
Mjkramer21 Mjkramer21 is offline
Awaiting Email Confirmation
 
Join Date: Mar 2004
Location: Orem, Ut
Posts: 36
Mjkramer21 is on a distinguished road

help with class functions


Hey Guys, can anyone tell me why I'm getting this error:

Quote:
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
C:\UVSC\CNS1250\projects\shapes\shapes.h:
Fatal F1003 c:\Borland\Bcc55\include\stdcomp.h 5: Error directive: Must use C++ for STDCOMP.H
*** 1 errors in Compile ***

Tool completed with exit code 1

when I try to compile 'shapes.cpp'?

CPP / C++ / C Code:
//---------------header file(Shapes.h)----------------------------------
#ifndef shapesH
#define shapesH

#include <iostream>
using namespace std;

#include <cstring>

class Shape
{
      private:
              string name;
	 string color;
      public:
              Shape(string name, string color);
	 string getName();
	 string getColor();
};

class square : public Shape
{
       private:
             double sLength;
       public:
             square(string name, string color, double Length);
	setLength();
	getLength();
	calcArea();
};

class circle : public Shape
{
        private:
             double radius;
        public:
             circle(string name, string color, double Rad);
	getRadius();
	setRadius();
	calcArea();
};
#endif
//--------------implementation file(shapes.cpp)------------------------
#include "shapes.h";

#include <iostream>
using namespace std;

#include <cstring>

Shape::Shape(string Sname, string Scolor)
{
	name = Sname;
	color = Scolor;
}

//these two function definitions (getName & getColor) are whats giving me a 
//me a problem I think. Does it not like me returning strings or something?

string Shape::getName()
{
    return name;
}
string Shape::getColor()
{
    return color;
}

Before anyone snaps at me for the format of the code, I spent a few minute aligning everything all nice and neat for ya, but it still posts the way it did.
  #2  
Old 22-Apr-2004, 20:38
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,281
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by Mjkramer21
Hey Guys, can anyone tell me why I'm getting this error:
...
when I try to compile 'shapes.cpp'?
All I can figure out is that
1) shapes.h is including stdcomp.h -- through iostream?
2) for some reason the compiler is not compiling in C++ mode but in C mode.

I notice you are including iostream in both shapes.h and shapes.cpp. I don't see anything in shapes.h that uses iostream unless I missed something. Try removing that include. And in the .cpp put the iostream include first.


Quote:
Originally Posted by Mjkramer21
Before anyone snaps at me for the format of the code, I spent a few minute aligning everything all nice and neat for ya, but it still posts the way it did.
Probably because there are tabs. Use only spaces. There is probably a setting in your editor/IDE to add spaces instead of tabs.

I discovered years ago that tabs cause formatting problems so I stopped using them in the 80's.
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
  #3  
Old 23-Apr-2004, 09:23
tay's Avatar
tay tay is offline
Junior Member
 
Join Date: Jan 2004
Posts: 77
tay will become famous soon enough
maybe shape.h was include inside ur library

or square and circle also include inside ur library

u try to rename above this 3
i think i shall work
__________________
challenges are make life interesting,
overcome them is make life meaningful.
 
 

Recent GIDBlogStupid Management Policies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 08:10.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.