Reputation: 11
I have difficulties using VS2019 to compile my C++ code.
I have Person.h header file:
#ifndef PERSON_H
#define PERSON_H
#include <string>
using namespace std;
namespace PersonClass {
struct Person {
public:
Name name;
int age;
};
struct Name {
public:
string firstName;
string lastName;
};
}
#endif
And here is my main.cpp:
#include "pch.h"
#include <iostream>
#include "Person.h"
using namespace std;
int main()
{
return 0;
}
When I compile this file I got following error:
Can someone teach me how to fix this problem?
Upvotes: 1
Views: 3984
Reputation: 2450
struct Name
has not yet been defined when you attempt to make use of it. Define struct Name
before you define struct Person
.
Upvotes: 3