Yotam
Yotam

Reputation: 10695

c++ Why do I get "does not name a type" error?

In my main class I have:

#include "main.h"
outPut O;
int main(){
...
}

where the main.h file has #include "outPut.h"

the "outPut.h" line has:

#ifndef OUTPUT_H
#define OUTPUT_H

#include <iostream>
#include <fstream>

    #include "properties.h"
    #include "particles.h"

    class outPut{
     public:
      outPut();
      std::ofstream file;
      void show(lipid * l);
    };

    #endif

and the outPut.cpp:

#include "outPut.h"

outPut::outPut(){
}

When I compile this I get the error:

main.cpp:3: error: ‘outPut’ does not name a type

Why so?

Thanks...

Edit, found it. main.h wasn't saved and the #include "outPut.h" was canceled.

Upvotes: 0

Views: 5691

Answers (2)

ssegvic
ssegvic

Reputation: 3142

grep for OUTPUT_H in all source files. You might have inadvertently defined the include guard in some other header which is included earlier than outPut.h.

Upvotes: 0

alternative
alternative

Reputation: 13042

You need to #include "outPut.h" in main.cpp.

Upvotes: 2

Related Questions