Okays, I tried it (finally) again but still didn't get it to work. Nor compilers, linkers or anything else. I noticed that even pragma didn't work now, it just seemed to fix "unresolved externals" of constructor and destructor... It didn't work when I added one normal function...gave unresolved again I read about makefile but I didn't find a way to edit it, it was just readable.
As I said above, if you post all of your updated files and your exact compiler error/warnings, then I can give it a try on my side to see if I can get it working, without things like "pragma", etc.
So, here are my 3 files excatly how they are, and errors by running the program (compile & link):
Project1.cpp:
Code:
#include "a.h"
int main() {
A b;
b.draw();
getch();
}
a.h:
Code:
#ifndef A_H
#define A_H
#include <conio.h>
#include <stdio.h>
class A {
public:
A();
~A();
void draw();
private:
int o;
};
#endif
a.cpp:
Code:
#ifndef A_CPP
#define A_CPP
#include "a.h"
A::A() {
o = 3;
}
A::~A() {}
void A::draw() {
printf("%i", o);
}
#endif
Errors:
[Linker Error] Unresolved external 'A::~A()' referenced from D:\PELIT\FOREST - OBJ\PROJECT1.OBJ.
[Linker Error] Unresolved external 'A::A()' referenced from D:\PELIT\FOREST - OBJ\PROJECT1.OBJ.
[Linker Error] Unresolved external 'A::draw()' referenced from D:\PELIT\FOREST - OBJ\PROJECT1.OBJ.
In a way I hope you'll get those errors too or there is something else wrong?