I am having a problem changing the value in line 47. I can't find the documentation that shows how to change the data. Eventually I will be moving this to the CSector.h class. I am just testing to see if the desired action takes place in the sector class.
#include <iostream>
#include "CSpecies.h"
#include "CItem.h"
#include "CShip.h"
#include "CPlayer.h"
#include "CAlien.h"
#include "CAmmo.h"
#include "CArmor.h"
#include "CBeam.h"
#include "CCargo_Hold.h"
#include "CComputer.h"
#include "CEngine.h"
#include "CHull.h"
#include "CMissile.h"
#include "CProjectile.h"
#include "CPwr_Gen.h"
#include "CSector.h"
#include "CSensor.h"
#include "CShield_Gen.h"
#include "CWeapon.h"
usingnamespace std;
void movetest(string move);//test function
int main()
{
//test data start
CShip a;
CSector s0001;//variables have to start with a letter or _
CSector s0002;
s0001.sete_north(true);
s0001.setnorth_ID(0002);
s0001.sete_south(false);
s0002.sete_south(true);
s0002.setsouth_ID(0001);
s0002.sete_north(false);
//test data ends
return 0;
}
void movetest(string move)//test function
{
string newpos = move;
if(move == "n"||"north" && s0001.gete_north())
{
a.setloc(s0001.getnorth_ID());
}
}
The compiler errors say:
C:\Users\jason and veronica\Desktop\Dashboards\Projects\Enemy Mine\main.cpp||In function 'void movetest(std::string)':|
C:\Users\jason and veronica\Desktop\Dashboards\Projects\Enemy Mine\main.cpp|47|error: 's0001' was not declared in this scope|
C:\Users\jason and veronica\Desktop\Dashboards\Projects\Enemy Mine\main.cpp|49|error: 'a' was not declared in this scope|
I don't recall having this problem before. But I suspect I will have to use pointers to do the deed. I am having such problems with pointers, even with all the tutorials I am reading about them.
Some insite will be appreciated. Thanks ahead. :o)
You need to pass s0001 into your function, as a pointer or otherwise, or my personal suggestion would be to add this function to your 'CSector' class as member function.
Thank you computergeek01. I was planning to do that. I don't know why I didn't just do that in the first place. And it was just gonna be a simple test. It became more complicated though. Time to pop the function in. I guess I just needed a little push. It sure would solve a few problems and it needs to go in anyway. Thanks again. But could you tell me how to pass s0001 as a pointer? It would help a lot in the rest of the program.
Well, the only reason I ask is so you can slap me with the logic as to why one or the other would be a serious miscalculation in judgement. (Or something like that.) I am still having problems with pointers and references.