how to define global const class variable [modified]
-
Hello :) , I'm trying to define a global const [Class] varibles in a MFC application. This class holds an array of variables that I like to assign at the beginning and I will use this variable [and its stored const values] in my program in different classes[]. Now what I'm doing is to add a blank cpp file to my project and then I define this class variable there.
#include "MyInfoArrayClass.h"
const CMyInfoArrayClass g_Info;
g_Info.Add(data1);
g_Info.Add(data2);
...but compiler dose not see the definition and intellisense shows the type of g_Info as int and returns SYNTAX error and redefinition of basic type. Even when I place class definition in a header file and include header file in the source file compiler returns same errors. [I have done this with an char type or int type, I mean I have defined a global char or int variable, and I had no problem but when I want to define a class type variable I encounter trouble.] Where I made a mistake:confused: thanks :)
modified on Saturday, August 30, 2008 4:13 AM
-
Hello :) , I'm trying to define a global const [Class] varibles in a MFC application. This class holds an array of variables that I like to assign at the beginning and I will use this variable [and its stored const values] in my program in different classes[]. Now what I'm doing is to add a blank cpp file to my project and then I define this class variable there.
#include "MyInfoArrayClass.h"
const CMyInfoArrayClass g_Info;
g_Info.Add(data1);
g_Info.Add(data2);
...but compiler dose not see the definition and intellisense shows the type of g_Info as int and returns SYNTAX error and redefinition of basic type. Even when I place class definition in a header file and include header file in the source file compiler returns same errors. [I have done this with an char type or int type, I mean I have defined a global char or int variable, and I had no problem but when I want to define a class type variable I encounter trouble.] Where I made a mistake:confused: thanks :)
modified on Saturday, August 30, 2008 4:13 AM