Is it possible to define a class (not interface) outside of any namespace?
The #define creates a macro, which is the association of an identifier or parameterized identifier with a token string. After the macro is defined, the compiler can substitute the token string for each occurrence of the identifier in the source file.
#define in C is a directive which is used to #define alias.
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
#define allows you to make text substitutions before compiling the program. Here's an example : #define MAX 70. Before compilation, if the C++ preprocessor finds MAX as one word (so words like MAXIMUM will not be affected), in the source code, it replaces it with the number 70.
Ran a test and yes you can. Here's my code built off of a Console App:
using System;
using System.Text;
namespace With_Console_App
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("This will output something: ");
Console.ReadLine();
some.Print();
Console.ReadLine();
}
}
}
class some
{
public static void Print()
{
Console.WriteLine("something");
}
}
Yes, you can define a class outside of a namespace. Per juharr it ends up in the default global namespace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With