简体   繁体   中英

Type Could Not Be Resolved Error

I'm a newbie to C++ and here I got one stupid question.

utility.h:

#ifndef UTILITY_H_
#define UTILITY_H_

 using namespace std;

#include <iostream>

enum Error_code {success, fail, range_error, underflow, overflow, fatal,
          not_present, duplicate_error, entry_inserted, entry_found,
                internal_error};


#endif /* UTILITY_H_ */

Stack.h:

#ifndef STACK_H_
#define STACK_H_

#include "utility.h"

typedef double Stack_entry;

class Stack {
public:
    Stack();
    ~Stack();
    bool empty();
    Error_code push(const Stack_entry &item);


#endif /* STACK_H_ */

These two header files are the only files in my project right now, and they're in the same folder. However, the Error_code in the Stack.h is always reported to be "Type could not be resolved". BTW, I'm using Eclipse on Mac Os X, and I've installed CDT.

Is there anyone has idea about this error or has been experiencing this? Thanks!


Sorry that I forgot to paste the header file for the Node, but it has the same problem with Error_code. Now I've removed that part.Here's the error message (sorry I'm not allowed to post image):

Description: Type 'Error_code' could not be resolved

Resource: Stack.h
Path: /StackImplementation/header
Location: line 21
Type: Semantic Error

Also I forgot to mention that these two file can be compiled by g++ command, but Eclipse always report the type error.


Wierd...somehow I recreated the project and the error disappeared.. Thanks all guys!

Where is the Node type declared?

protected:
    Node *top_node;

Nit ~ "Node" isn't defined in this chain? Depending on your tools, that could be obfuscating your answer. Everything else seems fine. Even stubbed out a .cc to test it out ~

#include "stack.h"

bool Stack::empty() {
    return true;
}

Error_code Stack::push(const Stack_entry &item) {
    return success;
}

Maybe you can see something wrong in your .cc besides Node not being defined?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM