![]() |
|
#1
|
|||
|
|||
Problem with an int arrayWell, the second lab is much easier... logically I get it all. I'm just running into a problem with an array I need to get working.
Basically it's a piece of the knight's tour. Not the entire program. I have to write a method that will check if the square the knight is jumping to is a valid move. Meaning it's not off the board, and the knight hasn't visited it before. Seems very short and simple, and the main is just how I wanted to display it to him in class, not what will be the tour program at all. The only problem is in the method validMove itself. Here's what I've got. CPP / C++ / C Code:
I commented out where I'm getting my problems. Why am I not able to look at a specific array location and check it? I thought it might be that it's not sent to the method, but any attempts to do that resulted in more compiler errors, and I'm not sure it even needs it. You can remove the comments and see what errors I got from it... Hopefully someone can offer me some sort direction. I'd appreciate it. |
|
#2
|
|||
|
|||
|
Quote:
You are saying that you want the string boardType[maxSize][maxSize] to be an alias for int. For instance: CPP / C++ / C Code:
Prints: 2 remove the typedef and simply say int boardType[max][max]; Or bool boardType[max][max]; [edit] To better illustrate: Using the above example CPP / C++ / C Code:
On my system the output is: Type x i Type y i Output of name() is system dependant however, you should notice that they are the same type. |
|
#3
|
||||
|
||||
|
Yeah, what he said.
Also, your if is: CPP / C++ / C Code:
CPP / C++ / C Code:
CPP / C++ / C Code:
But then again, to be perfectly accurate, you really need CPP / C++ / C Code:
__________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
|
#4
|
|||
|
|||
|
One last thing I'm weird on...
CPP / C++ / C Code:
Having not messed with bool enough, or classes and methods in general, I don't know how to do my last little tweak. I want to get the couts outside of validMove and into main. Something like... CPP / C++ / C Code:
Now, obviously I know that doesn't work, I tried it. I just don't know how to do a test on the returned value from the method. Never done it before, and can't find it in the textbook I have. |
|
#5
|
||||
|
||||
|
Quote:
Maybe something like, CPP / C++ / C Code:
would be more appropriate. Mark __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
Recent GIDBlog
2nd Week of IA Training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| array problem | vaha | C Programming Language | 9 | 18-May-2005 12:23 |
| problem modifying an array of char in a function | ronin | C Programming Language | 10 | 28-Mar-2005 18:15 |
| template comiling problems - need expert debugger! | crq | CPP / C++ Forum | 1 | 01-Feb-2005 21:26 |
| problem reading to a dynamic array | noamfrie | C Programming Language | 9 | 02-Jan-2005 18:35 |
| Problem in array | Kay Chan | C Programming Language | 2 | 05-Oct-2004 21:16 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The