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!!
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.
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".
# 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>
usingnamespace std;
this is point imp
1 2 3
# include "pointType.h"
# include <iostream>
usingnamespace std;
this is the client
1 2 3 4 5 6 7 8 9
# include <iostream>
# include "circle.h"
# include "pointType.h"
usingnamespace std;
int main()
{
...rreturn 0}
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.