| | |
only const static integral data members can be initialized inside a class or struct
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2007
Posts: 17
Reputation:
Solved Threads: 0
only const static integral data members can be initialized inside a class or struct
0
#1 Jul 19th, 2007
I was told not to have global variables and given an example. Ifollowed it and now I get this error:only const static integral data members can be initialized inside a class or struct
on lines 50-85
on lines 50-85
C++ Syntax (Toggle Plain Text)
#define STRICT #define ORBITER_MODULE #define ENG 1 #define START 2 #define STOP 3 #include <orbitersdk.h> #include <cstdio> #include <cmath> #include <string> #include "OrbiterSoundSDK3.h" #include <stdio.h> // ============================================================== // Shuttle-PB class interface // ============================================================== class Chariot: public VESSEL2 { public: Chariot (OBJHANDLE hVessel, int flightmodel); // : VESSEL2 (hVessel, flightmodel) {} void clbkSetClassCaps (FILEHANDLE cfg); void DefineAnimations(void); void clbkPostCreation (void); void clbkPreStep (double simt, double simdt, double mjd); void clbkPostStep (double simt, double simdt, double mjd); int clbkConsumeBufferedKey (DWORD key, bool down, char *kstate); private: double i = 0; double i2 = 0.5; double i2l = 0.5; double i2r = 0.5; double i3 = 0; double t1 = 1; double i4 = 0; double i5 = 0; double i6 = 0; double st = 0; double pld = 0; double cen = 0; double fb = 0; double sign = 0; double pit2 = 200; double sp = 190; int start = 0; double i8 = 0; double main_on = 0; double retro_on = 0; THRUSTER_HANDLE th_main; THRUSTER_HANDLE th_retro; THRUSTER_HANDLE th_rcs[4], th_group[2]; UINT animactive6; UINT animactive5; UINT animactive7; UINT animactive8; UINT animactive9; UINT animactive10; int MySoundID; double canopy = 0; double lfdoor = 0; double lrdoor = 0; double rfdoor = 0; double rrdoor = 0; double rhatch = 0; UINT anim_wheel; UINT anim_wheelleft; UINT anim_wheelright; UINT anim_wheelleftrev; UINT anim_wheelrightrev; UINT anim_leverleft; UINT anim_leverright; UINT anim_lfdoor; UINT anim_dome; UINT anim_lrdoor; UINT anim_rfdoor; UINT anim_rrdoor; UINT anim_rhatch; }; Chariot::Chariot (OBJHANDLE hVessel, int flightmodel) : VESSEL2 (hVessel, flightmodel) { DefineAnimations (); }
Last edited by ~s.o.s~; Jul 19th, 2007 at 2:43 pm. Reason: Removed the tex tags.
Re: only const static integral data members can be initialized inside a class or struct
0
#2 Jul 19th, 2007
imsorryicantunderstandwhatyourquestionisbecauseitlookslikethis
Try rearranging your post without the LaTex tags
Although, with reference to the subject line - look at the private members in your class (Of which there are far, far too many... if i were you, the first thing i'd do would be to look at a way to cut them down.. such as an array)
You can't directly assign a value to a data member in the class, you need to initialise them in the class constructor instead.
Try rearranging your post without the LaTex tags
Although, with reference to the subject line - look at the private members in your class (Of which there are far, far too many... if i were you, the first thing i'd do would be to look at a way to cut them down.. such as an array)
You can't directly assign a value to a data member in the class, you need to initialise them in the class constructor instead.
Last edited by Bench; Jul 19th, 2007 at 9:23 am.
¿umop apisdn upside down? •
•
Join Date: Jun 2007
Posts: 17
Reputation:
Solved Threads: 0
Re: only const static integral data members can be initialized inside a class or stru
0
#3 Jul 19th, 2007
I fixed it. I was told not to have global variables. And send an example
Now I need to see hwta is going on with this:
What happens is event though start =1 the sprintf shows it is 0 and the set thrusterlevel part doesn't work.
Now I need to see hwta is going on with this:
C++ Syntax (Toggle Plain Text)
// -------------------------------------------------------------- // Vessel cleanup // -------------------------------------------------------------- DLLCLBK void ovcExit (VESSEL *vessel) { if (vessel) delete (Chariot*)vessel; } void Chariot::clbkPreStep (double simt, double simdt, double mjd) { sprintf(oapiDebugString(),"start %2.2f", start ); if (0==start){ SetThrusterGroupLevel (THGROUP_MAIN, 0); SetThrusterGroupLevel (THGROUP_RETRO, 0); SetThrusterGroupLevel (THGROUP_ATT_YAWLEFT, 0); SetThrusterGroupLevel (THGROUP_ATT_YAWRIGHT, 0); } }
![]() |
Similar Threads
- shouldn't this work?? (C++)
- Const object declaration without default constructor (C++)
- MFC problems (C++)
- Dynamic arrays inside a class? (C++)
- accessing private data members (C++)
Other Threads in the C++ Forum
- Previous Thread: convert these C++ codes to VB .NET ?
- Next Thread: How to convert WideString to THashString?
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count database delete deploy desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





