Why public ref in c++ class definition

Mr Newbie picture Mr Newbie · Aug 5, 2009 · Viewed 20.9k times · Source

First of all I want to make clear that 'm all new to C++, so this might be a simple and somewhat obvious question. In the C++ book I'm reading called C++ Primer, a class is defined by writing:

class classname{
public:

private:

};

However, in VS2008 the compiler didnt like this. But by adding public ref before class, as in:

public ref class classname{

it went through in the compiler. Can anyone please explain what the difference is between defining only with class and with public ref class? I would really appreciate it.

Answer

1800 INFORMATION picture 1800 INFORMATION · Aug 5, 2009

The ref syntax is a Microsoft extension used only in Managed C++. By the sounds of things you have flicked the /clr compiler switch on by mistake when creating your project. If all you want to do is to create real C++ programs, then you will want to revert that.