tyty5949
tyty5949

Reputation: 1530

Undeclared identifier error c++, What did I do wrong i have no clue?

I am getting this error when ever i run this project

  6 error C2065: 'Engine_in':undeclared identifier

I really dont know what i have done wrong. Usually i can figure it out and know what i did wrong but the books i have dont go into depth on seperate file classes. I honestly do not know where the error is coming from. I have googled it but everyones problems are specific, so that is why i am resorting to asking you to solve my problems. I appologize in advance for me not knowing much.

I have this class 'Engine_debug.cpp'

//Engine Debugger

#include<iostream>
#include "Engine_debug.h"
#include "Engine_in.h"

using namespace std;

Engine_debug::Engine_debug()
{
    Engine_in input;
}

Then i have this header 'engine_debug.h'

#ifndef Engine_debug_H
#define Engine_debug_H

class Engine_debug
{
    public:
        Engine_debug();
    protected:
    private:
}

#endif

I also have this class 'Engine_in.cpp'

//Engine input

#include<iostream>
#include<string>
#include "Engine_in.h"

using namespace std;

Engine_in::Engine_in()
{

}

string askYN(string question, int format)
{...working code}

And one more, the other header 'Engine_in.h'

#ifndef Engine_in_H
#define Engine_in_H

class Engine_in
{
    public:
        Engine_in();
        std::string askYN(std::string question, int format = 0);
    protected:

    private:
};

#endif

If anyone knows what i did wrong and would like to explain to me, please do, thanks.

Upvotes: 0

Views: 61

Answers (1)

Mahesh
Mahesh

Reputation: 34615

If it isn't a typo, you forgot to write class name while defining the member function.

string Engine_in::askYN(string question, int format)
    // ^^^^^^^^^^ Missed during member function definition

Not sure if that causes the kind of error message the compiler is complaining about.

There is also a missing ; at the end of Engine_debug class definition. Credits Jesse.

Upvotes: 1

Related Questions