the base class is not found!

hi every one im working with some exersies which include inheretence
every thing is fine except that the compiler dose not recognize the base clase
it says Error Cannot open include file: 'pointType.h': No such file or directory
here is part of the code


what should i do any idea im so stucked iv tried many things!!

this is psrt of the code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# include "pointType.h"
# ifndef circle_H
# define circle_H


class circle : public pointType
{
public:
	//constructor
	circle(double r=0.0,int x=0,int y=0);
	void setRadius(double);
	double getRadius()const;
	double area()const;
	double circumference()const;
	void printR();

protected:
	double radius;
}
#endif  


Last edited on
Yoy should write :

#include "pointType.h"

instead,and remember if you use the " " instead of < > your compiler will look for the header in the same directory where your program files are to be stored,if you use < > it will look for it on the include directory of your c++ IDE.
mike i did but it dosent work the erorr is keep showing
i feel ill become crazey.
It sounds like you've dropped that code above straight into your main.cpp???
no,its the header file of the cirle class
....
i have 2 classes the point class
and the circle class and the implemenation of the functions are seperated from the class!
As Mike Sandy told you above you have three options

1.First put you header file " pointType.h" inside the folder of your compiler where you can find the rest of the header files such as iostream.h.If you do so just type #include <pointType> .

2.Every compiler has an option to give directions for the folder where it must search in order to find the header file.For example i use visual studio 6,from tools->options->directories i choose the directory i want to be automaticaly included.Just type then #include "pointType"

3.You can gine the hole path where you have saved your header file,for example if you have it on you desktop just type #inlcude"C:\mydesktop\pointType.h".
Last edited on
iv tried the 3rd and the 2nd it didnt work and the 1st i dont now how to do it
ps:im using visual studio 8 will it make difference..?!
this is the first lines of my codes if it can help

pointType .h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

# ifndef pointType_H
# define pointType_H
class pointType{
protected:
	int x,y;
public:
	// constructor
	pointType(int x=0,int y=0 );
	//mutator function
	void setXY(int,int);
	//accessor function
	int getX()const;
	int getY()const;
	void printXY();//dosent make sense sinse we have accses to the privet !



};

# endif 


this is circle imp
1
2
3
4
5
6
# include "circle.h"
# include <iostream>
# include "pointType.h"
# include <cmath>
 using namespace std;


this is point imp
1
2
3
# include "pointType.h"
# include <iostream>
using namespace std;


this is the client
1
2
3
4
5
6
7
8
9
# include <iostream>
# include "circle.h"
# include "pointType.h"

using namespace std;

int main()
{
...rreturn 0}


is there smth wrong
i did maybe!
Actually the correct way to include .h files in other location is to write a Makefile or some bash scripts. Inside the Makefile you do a symbolic link of those other folder .h files to your current directory. So in your program you just put "pointType.h" as in referencing current folder. But the file is just a symbolic link where the actual location is somewhere else. If source header changes, you will automatically see the change in your current directory.

pointType.h reside in /abc/def

Your program is in /abc

So your code write #include "pointType.h"

Then in /abc you do a ln -s /abc/def/pointType.h pointType.h

Then in /abc you will see a file called pointType.h but it is actually located in /abc/def




ARWA just go program files microsoft-->visual studio.There you should search for a folder include where there are saved the header files. Put your headers there.
ok
^_^

thanks its working now..
Topic archived. No new replies allowed.