Classes: adding a new variable produces errors

This is a discussion on Classes: adding a new variable produces errors within the C++ Programming forums, part of the General Programming Boards category; Hi all, I have a class inside a program and at the moment it works fine. But when I add ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    5

    Question Classes: adding a new variable produces errors

    Hi all,
    I have a class inside a program and at the moment it works fine. But when I add one more variable to it - then I run into the errors in the program - it actually runs, but all the other variables have some random number. I guess I run into some memory issues.
    So here is my class:

    Code:
    class plasma_class
    {
    public:
    	float PeakDensity;
    	short DensityProfileX;
    	short DensityProfileY;
    	short NumberOfSpecies;
    	double RoughnessAmplitude;
    	double RoughnessPeriod;
    	//double FrontPreplasmaLength;
    	//double RearPreplasmaLength;
    
    	struct specie_class
    	{
    		int ParticlesPerCellX;
    		int ParticlesPerCellY;
    		int Charge;
    		double Mass;
    		double ReciprocalMass;
    		int NumberOfParticles;
    		int CellsPlasmaX;
    		int CellsPlasmaY;
    		double StartX;
    		double EndX;
    		double StartY;
    		double EndY;
    		double PeakCharge;
    
    	struct particle_class
    		{
    		//public:	
    			double x;
    			double y;
    			double p_x;
    			double p_y;
    			double p_z;
    			//double ExParticle;
    			//double EyParticle;
    			//double BzParticle;
    			double q;
    			short InsideVolumeFlag;
    		};
    
    		std::vector<particle_class> particle;
    
    		
    	};
    
    	std::vector<specie_class> specie;
    
    	plasma_class(const char *, simulation_class simulation);
    
    	void move(simulation_class simulation, fields_class &fields, int TimeStep);
    	
    
    };
    Problems start when I uncomment for example FrontPreplasmaLength. Could anybody help me understand all this stuff and resolve the problem

    Thanks in advance

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Did you recompile ALL the code that uses the class?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    5
    Cheers, Mats you saved the dummy once again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 01-18-2003, 01:32 AM
  2. About classes and HINSTANCE variable to Main
    By conright in forum Windows Programming
    Replies: 2
    Last Post: 01-01-2003, 08:00 PM
  3. Sharing a variable between classes of different .CPP files
    By divingcrab in forum C++ Programming
    Replies: 5
    Last Post: 07-07-2002, 03:57 PM
  4. Classes Compiler Errors
    By taiDasher in forum C++ Programming
    Replies: 5
    Last Post: 07-03-2002, 09:11 AM
  5. errors with classes (again)
    By neandrake in forum C++ Programming
    Replies: 1
    Last Post: 03-18-2002, 08:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21