Wednesday, November 10, 2010

What is the equivalent of C# #region in C++?

In C# you can hide your code, using regions, i.e. something like this. But it doesn't work in C++. What is the equivalent of the #region directive in C++?

#region Public methods
void SomeMethod()
{

}
#endregion

Solution: This should work in both .h/.cpp files in Visual Studio.

#pragma region
 void Test();
 void Test2();
 void Test3();
#pragma endregion

or with a comment like this:

#pragma region Region_Declarations
 void Test();
 void Test2();
 void Test3();
#pragma endregion Region_Declarations


No comments:

Post a Comment