Search found 35 matches

by indus
January 19th, 2013, 3:21 pm
Forum: Everything
Topic: How to instialize an array of classes( in progress )
Replies: 40
Views: 16725

Re: How to instialize an array of classes

What I did and it works: in the header file added a new constructor declaration class Particle { public: Particle( D3DGraphics *gfx, KeyboardClient *kbd ); Particle(int, int, int, int, D3DGraphics *, KeyboardClient *); Particle(){} ~Particle(); ... } added implementation in the cpp Particle::Particl...
by indus
January 19th, 2013, 2:51 pm
Forum: Everything
Topic: How to instialize an array of classes( in progress )
Replies: 40
Views: 16725

Re: How to instialize an array of classes

May be even pass pX, pY, vX and vY as parameters for the constructor and do the whole random stuff in the Game constructor.
by indus
January 19th, 2013, 8:17 am
Forum: Everything
Topic: How to instialize an array of classes( in progress )
Replies: 40
Views: 16725

Re: How to instialize an array of classes

Again nice, clean and very readable coding style from you :) One piece of advice. Once you access your class you dont need to use the scope resolution operator before every class element. void Particle::updatePosition() // on this line you tell the compiler that you operate in class Particle { Parti...
by indus
January 18th, 2013, 11:03 pm
Forum: Everything
Topic: How to instialize an array of classes( in progress )
Replies: 40
Views: 16725

Re: How to instialize an array of classes

You will have to initialize every single instance of the class separately. Use for loop for that. Game::Game( HWND hWnd,const KeyboardServer& kServer,const MouseServer& mServer ) : gfx( hWnd ), audio( hWnd ), kbd( kServer ), mouse( mServer ) { for(int i = 0; i < 10; i++) Charlie[ i] = new Particle (...
by indus
January 18th, 2013, 7:47 pm
Forum: Everything
Topic: creating a class [solved]
Replies: 9
Views: 3346

Re: I'd need some help with classes please [solved by Musi]

Classes are like pointers. Not something that you understand straight away after reading what they are and how are they being useful. The more you use them the more you understand them. Just dont give up. :D
by indus
January 17th, 2013, 1:40 am
Forum: Everything
Topic: How to instialize an array of classes( in progress )
Replies: 40
Views: 16725

Re: How to instialize an array of classes

It is blank because it takes forever to load all the sprites. He creates new surfacesequence for each element of the array so it take really long time to do that. Instead create one instance and use it by all the marines.
by indus
January 17th, 2013, 1:02 am
Forum: Everything
Topic: How to instialize an array of classes( in progress )
Replies: 40
Views: 16725

Re: How to instialize an array of classes

You seem to be right. And it also seems to work now. Just takes forever to load the sprites.
by indus
January 17th, 2013, 12:11 am
Forum: Everything
Topic: How to instialize an array of classes( in progress )
Replies: 40
Views: 16725

Re: How to instialize an array of classes

spawn class class Spawn { public: Spawn( Unit* units ) : units( units ) {} }; marine class class Marine : public Unit { public: Marine( std::wstring basename, unsigned int nSurfaces, unsigned int nHoldFrames, D3DCOLOR key = D3DCOLOR_XRGB( 255,255,255 ) ) : Unit( basename, nSurfaces, nHoldFrames, key...
by indus
January 16th, 2013, 11:49 pm
Forum: Everything
Topic: How to instialize an array of classes( in progress )
Replies: 40
Views: 16725

Re: How to instialize an array of classes

I am not able to compile your project at all.It gives me some linker error that does not say anything helpful. Probably somethings messed up with the project configuration. Anyway as I already wrote, you should just give us a small piece of code. Like the one I posted. Showing the constructor of the...
by indus
January 16th, 2013, 9:31 am
Forum: Everything
Topic: How to instialize an array of classes( in progress )
Replies: 40
Views: 16725

Re: How to instialize an array of classes

It is always better when you put a small code example showing what exactly are you trying to do and what isnt working. class A { int age; string name; A(int a , string b) : age(a), name(b) {} ~A(); }; A arrExample [2] = { {15, "John"}, {16, "Travolta"} }; vector <A> vectorExample { {20, "Quentin "},...