Thread: Why won't this work? (Returning strings)

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    3

    Why won't this work? (Returning strings)

    My compiler keeps telling me that "`string' does not name a type" and highlighting this line:
    Code:
    string asString(bool *walls, width, height) {
    (If you're curious, it's suppose to give a textual representation of a randomly generated maze.)

    Before you mention it, I've already got "#include <string>" and "using namespace std" in the code.

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Looks like width and height need to have types
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    3
    Thanks for that. I feel a bit dumb now. Unfortunately, it still won't work. So far:
    Code:
    string asString(bool *walls, int width, int height) {

  4. #4
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    I don't see anything wrong with that; the problem is probably elsewhere in your code.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  5. #5
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    is the line before this any clue?

    as mentioned, if your code is not excessively long try and post that so we can see if the error is somewhere else.

  6. #6
    Registered User
    Join Date
    Nov 2006
    Posts
    3
    Apparenty it was because I forgot to put a use a semicolon while closing a class. Unfortunately there seem to be a ton of other problems. I'm gonna try to figure them out on my own before posting again.
    Thanks anyway.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The Bludstayne Open Works License
    By frenchfry164 in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-26-2003, 11:05 AM
  2. Table mapping Strings to Strings
    By johnmcg in forum C Programming
    Replies: 4
    Last Post: 09-05-2003, 11:04 AM
  3. The best way to work with strings?
    By Devil Panther in forum C Programming
    Replies: 2
    Last Post: 06-28-2003, 10:34 AM
  4. correct way of returning strings
    By marsface in forum C++ Programming
    Replies: 5
    Last Post: 06-11-2003, 10:33 AM
  5. returning strings - function.
    By Vber in forum C Programming
    Replies: 11
    Last Post: 03-23-2003, 05:24 PM