开发者

"Functions may not be part of a struct or union" when trying to use a constructor for a struct

I am wondering if this is a compiler specific problem or not. I've seen examples of the use of constructors for a struct in C++.

I have so开发者_高级运维mething like:

struct Example
{
   Example()
   {
   }
};

I still get this compiler error "Functions may not be part of a struct or union". I am using the very old Borland 4.5 compiler (best not to ask why...).

(And yes, this is done in C++).


I can't help myself: Why?

Using a compiler that announces it's support for Windows 95 is sort of interesting. The C++ standard is from 1998, so anything published before that is perhaps not up to date? :-)

Other than that, the code is perfectly ok.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜