Error, Type name expected in bcb 2007

Hi guys,

I am porting a program into bcb2007 from vc6.0. Here is my problem.

I made a class called Point which is inherited by the class vertex.

Then i made a class called triangle which includes vertex.h. Now this has been tested in vc6.0 and works perfectly.

In bcb2007 i get the following errors.

[BCC32 Error] triangle.h(38): E2303 Type name expected
[BCC32 Error] triangle.h(38): E2139 Declaration missing ;

for this line:
 
vertex *ptr;  //three adjacent vertices p1,p2,p3 


It is as if the vertex class does not exist. I have had many errors in the triangle class wherever the parameter is vertex, so i commented everything out but the above line. I have exhausted almost all my options.

Any help much appriciated!

Is vertex.h in the right directory?
Yes, they are all in the same directory.
I also want to add that when i compile point and triangle classes they build successfully, when i build vertex it points me out to that line in triangle.h.

If i comment it out such that, Vertex is not used at all in Triangle, i have no problems from the compiler.

I also use Point class in triangle, as far as i know, there should be no problem using the base class and the derived class in a 3rd class that does not inherit from either.

i am trying to access embarcadero forums but for some reason i have not been able to open the page for the past few days...

Last edited on
Can you post the code?
Unfortunately i cannot, vertex.cpp is 2873 lines. I have removed Triangle from the project and it compiles normally. Would upcasting from vertex to point cause such a problem. I have tried dynamic_cast<Point> instead of just (Point) but it doesnt solve anything. I'm at a loss because it works in visual studio 2005/2008 and 6.0 but it refuses to work in bcb2007. I am at a loss and the error messages are of no use.

It wouldn't.

Ok, can you post the header files at least?
I think i have solved my issue, for some reason the order which i added them to my project made a difference, i reloaded them and it did not give me errors about vertex *ptr but instead my overloaded operators, two of them did not take const parameters, changing them to const let me compile. I just wish the error messages were more helpfull.

1
2
	Point operator-(Point&); // Error in bcb2007 but worked in vc6 till vc2008
	Point operator-(const Point&); // OK in bcb2007 


Thank you for your time.
the binary operator- should be a const member function as well.

int a, b, c;

a = b - c;

does not modify b.
Yes i would agree but i actually use it to minus distances since im moving things around in 3D space.
Topic archived. No new replies allowed.