Lin Li
Lin Li

Reputation: 11

VS2019 C++ unknown override specifier

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:

  1. 'name': unknown override specifier missing type specifier - int assumed.
  2. Note: C++ does not support default-int

Can someone teach me how to fix this problem?

Upvotes: 1

Views: 3984

Answers (1)

jkb
jkb

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

Related Questions