The following is the code I currently cannot resolve:
error.cpp - the main module
#include <iostream>
#include "a.h"
#include "k.h"
int main()
{
A a;
std::cout << "Hello World!\n";
func();
}
a.h
#pragma once
struct A {
};
k.h - just another module containing one function
#pragma once
void func();
k.cpp
#include "a.h" // for struct A
#include "k.h" // for function prototype
void func() {
struct A a;
}
What I did is the following:
I have soem MFC code, which was not compiling anymore.
What I did was I created another Single Document application and dumped all the class modules into the newly created directory and added them to my project. Now I wanted to use the functionality of one of the classes I had included and in OnInitialUpdate
I created an object from my class.
The error messages resembled the error messages I got from above code: The error message changes from the following ...
Code Description Project File Line
LNK2019 unresolved external symbol "void __cdecl func(void)" (?
func@@YAXXZ) referenced in function main error
C:\Projects\C++Projects\error\error.obj 1
LNK1120 1 unresolved externals error
C:\Projects\C++Projects\error\x64\Debug\error.exe 1
to the following:
C2079 'a' uses undefined struct 'main::A' error
C:\Projects\C++Projects\error\error.cpp 8
E0070 incomplete type is not allowed error
C:\Projects\C++Projects\error\k.cpp 5
lnt-uninitialized-local Local variable is not initialized. error
C:\Projects\C++Projects\error\k.cpp 5
C2079 'a' uses undefined struct 'A' error
C:\Projects\C++Projects\error\k.cpp 5
lnt-uninitialized-local Local variable is not initialized. error
C:\Projects\C++Projects\error\error.cpp 8
after renaming function fct() to func in k.pp!!!
What is wrong?