function prototypes and arguments in classes

Hi,

I'm writing a code, which looks like this (simplified...)

----------------
routes.h
----------------
1
2
3
4
5
6
7
8
9
#include "buses.h"
class routes
{
    friend class buses;
    public:

    private:

}


------------------
buses.h
------------------
1
2
3
4
5
6
7
8
#include "routes.h"
class buses
{
     public:
         void set_bus_data (int , int , ? (A) )
     private:

}

------------------
buses.cpp
------------------
1
2
3
4
5
void buses::set_bus_data(int i, int j, ? (B) )
{


}



---------------
main.cpp
--------------------
1
2
3
4
5
6
7
8
9
10
11
12
#include "buses.h"
#include "routes.h"
int main ( )
{
     routes* r = new routes[10];
     buses* b = new buses[40];

     for (int i=0;i<40;i++)
     {
           b[i].set_bus_data(3,4,? (C) );
     }
}

-------------------------

Could someone tell me what should A, B and C be, in the above piece of code. I want to use all objects of routes in the set_bus_data function


I've tried
(A) - routes*
(B) - routes* p so that i can access members by (*(p+index)).member....
(C) - r

But I am running in to the following errors:

In file included from routes.h:4:0,
                 from routes.cpp:12:
buses.h:15:16: error: ‘routes’ has not been declared
In file included from routes.h:4:0,
                 from buses.cpp:12:
buses.h:15:16: error: ‘routes’ has not been declared
buses.cpp:68:6: error: prototype for ‘void buses::display(routes*)’ does not match any in class ‘buses’
buses.h:15:8: error: candidate is: void buses::display(int*)
In file included from routes.h:4:0,
                 from main.cpp:14:
buses.h:15:16: error: ‘routes’ has not been declared
main.cpp: In function ‘int main()’:
main.cpp:76:23: error: no matching function for call to ‘buses::display(routes*&)’
buses.h:15:8: note: candidate is: void buses::display(int*)
Firstly, did you forget to include buses.h in buses.cpp?
Also, http://www.cplusplus.com/forum/articles/10627/ (section 4)
I have included buses.h and routes.h in buses.cpp
make the forward declaration of router class before buses class.
Last edited on
@bluecoder: Thanks forward declaration helped
Topic archived. No new replies allowed.