I have class like below
#include <iostream>
#define Gb MemorySizeUnit.Gb
#define Mb MemorySizeUnit.Mb
#define Kb MemorySizeUnit.Kb
using namespace std;
enum MemorySizeUnit {Gb, Mb, Kb};
class Test
{
private:
MemorySizeUnit memSizeUnit;
int memorySize;
public:
void setMemory(const int memSize, MemorySizeUnit unit);
}
and i want to be able to do something like
Test test;
test.setMemory(20, Gb);// as opposed to test.setMemory(20, MemorySizeUnit.Gb)
Compiler does not like that in #define, i have a “.”
Just remove the
#definealtogether, enum values are placed in the outer namespace automatically. It’s not like C# or Java where the enum values have to be accessed through the enum name namespace, absnet ausing-like declaration.