.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

winSPMBT: Main Battle Tank- Save $6.00
winSPWW2- Save $6.00

   







Go Back   .com.unity Forums > Shrapnel Community > Space Empires: IV & V

Reply
 
Thread Tools Display Modes
  #1  
Old August 18th, 2006, 10:05 PM
PvK's Avatar

PvK PvK is offline
National Security Advisor
 
Join Date: Dec 1999
Posts: 8,806
Thanks: 54
Thanked 33 Times in 31 Posts
PvK is on a distinguished road
Default Re: OT: Stupid c++

Oh, sorry STL->std (bad human memory).

By "what syntax", I just meant what does your code look like. Yes, the line you wrote is the syntax I was trying to remember and suggest to you. Good job.

Yes, so the syntax for that would be something like:
Code:

// In the class definition file e.g. NarfClass.h
class NarfClass
{
// Constructor:
NarfClass( std::vector<Character> * pCVectorToUse );

// Method that does something with CVector:
void DoStuffWithCVector();

// The static storage of the Character Vector:
static std::vector<Character> * pCVector;
};



Code:
// In the class definition file e.g. NarfClass.cpp
#include "NarfClass.h"

NarfClass::NarfClass( std::vector<Character> * pCVectorToUse )
{
pCVector = pCVectorToUse;
}

void NarfClass:oStuffWithCVector()
{
int NumberOfCharactersInGame = pCVector->size();
// etc...
}



Code:
// In the class that stores the whole gamestate:
#include "NarfClass.h"

// The actual vector:
static std::vector<Character> CVector;

// The creation of a NarfClass object:
NarfClass NarfsNarf( &CVector );

// Now NarfsNarf is an object that can do stuff with CVector.
NarfsNarf.DoStuffWithCVector();


I may have a typo or be missing something, but that's about how I'd do it.

PvK
Reply With Quote
  #2  
Old August 18th, 2006, 10:15 PM
narf poit chez BOOM's Avatar

narf poit chez BOOM narf poit chez BOOM is offline
Shrapnel Fanatic
 
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
narf poit chez BOOM is on a distinguished road
Default Re: OT: Stupid c++

Thanks again.

For syntax, I tend to go with the needs of the moment.

So, you mean make a handler class for the Character class?

How do you declare something 'extern'?
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 01:20 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2026, Shrapnel Games, Inc. - All Rights Reserved.