Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6929659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:20:46+00:00 2026-05-27T11:20:46+00:00

This is the dumbest little problem I am having and I CANNOT find the

  • 0

This is the dumbest little problem I am having and I CANNOT find the reason.

I am aware that there are dozens and dozens of this error already asked, but every one I read was about the order of declaration, however, I declare my struct before I use it in a function, and still get the error.

Here is the header file:

#ifndef GRAPH_H
#define GRAPH_H


#include <iostream>
#include <string>
using namespace std;

class Graph {

    public:
    struct Room;

    // destructor
    ~Graph();

    // copy constructor
    Graph(const Graph &v);

    // assignment operator
    Graph & operator = (const Graph &v);

    //Create an empty graph with a potential
    //size of num rooms.
    Graph( int num );

    //Input the form:
    //int -- numRooms times
    //(myNumber north east south west) -- numRooms times.
    void input(istream & s);

    //outputs the graph as a visual layout
    void output(ostream & s , string str );

    //Recursively searches for an exit path.
    void findPath( Room * start );

    //Moves room N E S or W
    void move( Room * room , string direction );

    //inputs the starting location.
    void inputStart( int start );

    //Searches the easyDelete array for the room with the
    //number "roomNumber" and returns a pointer to it.
    Room * findRoom( int roomNumber );

    struct Room
    {
        bool visited;
        int myNumber;

        Room *North;
        Room *East;
        Room *South;
        Room *West;
    };

    private:

    int numRooms;
    int _index;
    int _start;

    Room ** easyDelete;
    string * escapePath;

    Room * theWALL;
    Room * safety;
};

#endif

The specific error is: error: "Room" does not name a type, and it is talking about my

Room * findRoom( int roomNumber );

function, which is supposed to return a pointer to a "Room." I have tried putting the actual definition of the struct where the "struct Room;" is, to no avail.

Edit: My apologies, it’s in my .C file when I use it:

#include <iostream>
#include <string>
#include "Graph.h"
using namespace std;

...

Room * Graph::findRoom( int roomNumber )
{
    ...
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:20:47+00:00Added an answer on May 27, 2026 at 11:20 am

    are you sure the error is pointing to this .h file? there shouldn’t be this error…

    if you write the implementation (in .cpp) like this

    Room * Graph::findRoom( int roomNumber );
    

    it should complain, because Room is a part of Graph:

    Graph::Room * Graph::findRoom( int roomNumber );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This could quite possibly be the dumbest question ever asked. Our client wants us
So this is the dumbest thing I've struggled with in awhile. I cannot get
This question has been asked before but that was three years ago and Microsoft
Okay - this is the dumbest glitch I have seen in a while: <!DOCTYPE
This error just started popping up all over our site. Permission denied to call
This code won't compile because there is an illegal reference to a static field.
This is my first attempts at creating a data-mart/warehouse and I am a little
This may or may not be the dumbest question ever. I'm using Restlet. When
This could turn out to be the dumbest question ever. I want to track
This is beyond both making sense and my control. That being said here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.