working with multiple files
Hello, I am having linker problems.
I want to have all my classes nicely defined in their own files. Just to test out the method I began with the following.
I made a simple test class called bird
in a seperate file called bird.h
bird.h
----------------------------------
#ifndef _BIRD_H
#define _BIRD_H
class bird
{
public:
bird();
};
#endif
---------------------------------
then I made a bird.cpp to hold the code
bird.cpp
--------------------------------
#include "bird.h"
bird::bird()
{
};
----------------------------------
the main looked like this
main.cpp
--------------------------------
#include <iostream.h>
#include "bird.h"
bird test;
void main()
{
};
---------------------------------
All that ran well, so I decided to expand on this and make another class, a vector class.
vector.h
-------------------------------
#ifndef _VECTOR_H
#define _VECTOR_H
class vector
{
public:
vector();
};
#endif
-------------------------------
and a vector.cpp
vector.cpp
------------------------------
#include "vector.h"
vector::vector()
{
};
-----------------------------
and that ran fine. SO i modified the bird class to include a vector
new bird.h
---------------------------
#ifndef _BIRD_H
#define _BIRD_H
#include "vector.h"
class bird
{
public:
vector position;
bird();
};
#endif
--------------------------
and now everything doesnt work, How can i make a class that uses another class. This is so confusing, what if I needed a class that used opengl functions, how would include everything. I hope you understand my problem. Please, help.
something...
that code should work. I guess you are not putting vector.h and vector.cpp files into your project workspace..
if you are not, for vc++ you should say from menu insert->add files to project, or sth like that..
if you are doing that, can you tell the errors you have when you compile..
hope that helps..
-----------
my quote is under construction
if you are not, for vc++ you should say from menu insert->add files to project, or sth like that..
if you are doing that, can you tell the errors you have when you compile..
hope that helps..
-----------
my quote is under construction
-----------my quote is under construction
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement