0

I am having some problems while compiling c++ on Atom. I had been getting an error trying to link a header file with my source. And without changing anything, it suddenly ran properly after one day. Now, I am trying to compile two source files and a header one and I am getting an error saying class not declared in this scope. These are my files:

Source1:

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

int main() {
  Perfect parfait ;
  parfait.opa();
  parfait.part();

  return 0;
}

Source 2:

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

void Perfect::opa() {
  cout << "Numerai" << endl;
}

int Perfect::part() {
  int i = 2+4;
  return i;
}

Header file:

#include <iostream>
#ifndef FILE_H_
#define FILE_H_

class Perfect {
public:
  opa();
  part();
};
    #endif
  • There is no definition of class `Perfect` anywhere in the code you're showing. Perhaps you might want to read a [good C++ book](https://stackoverflow.com/q/388242/1782465) to get a firmer grasp on the basics of the language. – Angew is no longer proud of SO May 26 '18 at 20:20
  • Sorry, I was making changes and posted the wrong file! I am pretty sure the code is correct. I think there is something wrong with Atom compiler. Any suggestions? – user9851117 May 26 '18 at 20:25
  • what command are you using to compile? And is that the header file? Cause you are missing the declaration of class `Perfect`. – Mike van Dyke May 26 '18 at 20:41
  • 2
    @user9851117 First off, Atom is a text editor/IDE, not a compiler. Second, can you please [edit] your question to post the correct code? And while compiler bugs are always possible, I doubt that's the case here. You probably have something wrong in your code. We can't tell for sure until you post a [mcve], though. – Angew is no longer proud of SO May 26 '18 at 21:06
  • I edited it to the correct files. Do you see anything wrong now? – user9851117 May 27 '18 at 13:40
  • What Atom packages are you using to "compile" your code? As mentioned, Atom is **not** a compiler, it's just an editor. Perhaps you mean that you're using some linter or static code checker package and that the tool cannot find your header file? – Gino Mempin May 29 '18 at 05:04
  • No, I don't, I use MinGW. Atom probably has nothing to do with it (sorry I'm new to this!) , as I ran it from command prompt and got the same mistake. Any ideas what is happening? Do you think there is something wrong with the compiler? – user9851117 May 29 '18 at 13:23

0 Answers0