Question

I tried the following code in C++ Builder XE4.

As I recall, struct type name can be used as type (no need to add "struct" in the variable declaration).

However, C++ Builder XE4 outputs compile error for pt1 declaration.

struct Point {
    int x, y;
};


void __fastcall TForm1::Button1Click(TObject *Sender)
{
    Point pt1; // error ( E2379 Statement missing ; )

    struct Point pt2;   // no error
}

The same code can be compiled without error on Ideone.com http://ideone.com/kVzrlc

Is the C++ Builder implementation of C++ struct somewhat different?

Was it helpful?

Solution

In C++Builder Point is a function has been defined in Classes.hpp. You should change your struct name (like TMyPoint) or use struct keyword in this case.

Note: In BCB you can use predefined and already accessible types for storing point data such as POINT, TPoint, ...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top