Original Post
Hi, I've read up on static variables for a bit and tried to impliment by static variable but failed. Here's what happeend!! Error: g++ -c -g -O0 Control.cpp -L/usr/local/lib -I/usr/local/include Control.cpp:3: error: expected constructor, destructor, or type conversion before '=' token Control.cpp:3: error: expected
//Control.cpp
#include "Control.h"
Control::totalControls=0;
Control::skinFileExtension=".shenu";
//Control.h
#if !defined(CONTROL)
#define CONTROL
#include <string>
#include <map>
#include <iostream>
#include "Singleton.h"
#include "Algorithms.h"
#include "Cookie.h"
#include "Parameter.h"
#include "Path.h"
#include "Config.h"
#include "Data.h"
#include "Skin.h"
typedef std::map<std::string, std::map<std::string, std::string>* > DataMap;
typedef Singleton<Algorithms> algorithms;
//header
class Control {
public:
Control(Cookie *para_Cookie, Path *para_Path, Parameter *para_Paramter);
~Control();
void SetSkinFile(std::string para_skinFile);
void SetConfig();
void SetConfig(std::string key, std::string value);
void SetData();
void SetDataMap();
void Display();
void DisplayCont();
void DisplayList();
void RedirectToList();
void RedirectToManager();
void Head();
void Tail();
static int totalControls;
const std::string skinFileExtension;
//end public:
private:
std::string skinFile;
Print controlPrint;
Cookie *controlCookie;
Path *controlPath;
Config *controlConfig;
Parameter *controlParameter;
Data *controlData;
DataMap controlDataMap;
Skin *controlSkin;
static const int maxLayersControls=5;
//end private:
};
#endif
,' or ;' before '=' token Control.cpp:4: error: expected constructor, destructor, or type conversion before '=' token Control.cpp:4: error: expected ,' or ;' before '=' token *** Error code 1 and just wanted to double check that I understand static correctly. So let's say I have a class called loop. and let's say the destructor of loop calls loop itself again. I can count the number of loops with a static int correct? So that when the loop has called itself 5 times, it will stop calling itself. Well, any kind of output, helpful or harmful will be appreciated as always!