Dude with not recognition class

Hi everybody, im new here and this is my first post.

I am a beginner in c++ and i have a problem with a part of my code.

The problem is that the program do not recognize the Class "Nave", i dont know why, and the funny thing is that is exacly the same structure than another class which is recognize by the program, called "Propietario".

Can you help me?? Because this is turning me crazy.

Thank you very much.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
 //.h

#ifndef NAVE_H
#define NAVE_H

#include "plataforma.h"
#include "registro.h"
#include <string>

using namespace std;

class Nave
{
public:

    Nave();
    Nave(string numRegistro, string propietario, float precio, int maxTripulantes, string propulsion);
    Nave(const Nave & N);
    ~Nave();

    void setNumRegistro(string numRegistro);
    string getNumRegistro();
    void setPropietario(string propietario);
    string getPropietario();
    void setPrecio(float precio);
    float getPrecio();
    void setMaxTripulantes(int maxTripulantes);
    int getMaxTripulantes();
    void setPropulsion(string propulsion);
    string getPropulsion();

private:
    string numRegistro_;
    string propietario_;
    float precio_;
    int maxTripulantes_;
    string propulsion_;

};

#endif // NAVE_H




//.cpp

#include "nave.h"
#include "plataforma.h"
#include "registro.h"


//--------CONSTRUCTORES  Y  DESTRUCTORES-----------


Nave::Nave()
{
    numRegistro_="";
    propietario_="";
    precio_=0;
    maxTripulantes_=0;
    propulsion_="";
}

Nave::Nave(string numRegistro, string propietario, float precio, int maxTripulantes, string propulsion)
{

    numRegistro_=numRegistro;
    propietario_=propietario;
    precio_=precio;
    maxTripulantes_=maxTripulantes;
    propulsion_=propulsion;
}

Nave::Nave(const Nave & N)
{
    numRegistro_=N.numRegistro_;
    propietario_=N.propietario_;
    precio_=N.precio_;
    maxTripulantes_=N.maxTripulantes_;
    propulsion_=N.propulsion_;
}

Nave::~Nave()
{

}



//----------SET Y GET-----------

void Nave::setNumRegistro(string numRegistro)
{

    numRegistro_=numRegistro;
}

string Nave::getNumRegistro()
{
    return numRegistro_;
}

void Nave::setPropietario(string propietario)
{

    propietario_=propietario;
}

string Nave::getPropietario()
{
    return propietario_;
}


void Nave::setPrecio(float precio)
{
    precio_=precio;
}

float Nave::getPrecio()
{
    return precio_;
}


void Nave::setMaxTripulantes(int maxTripulantes)
{
    maxTripulantes_=maxTripulantes;
}

int Nave::getMaxTripulantes()
{
    return maxTripulantes_;
}


void Nave::setPropulsion(string propulsion)
{
    propulsion_=propulsion;
}

string Nave::getPropulsion()
{
    return propulsion_;
}


What is the exact error message?
The error message was on the inheritance classes, "expected class-name before '{' token"
I suspect you either forgot to include nave.h in the cpp file that has main or you have a problem with the order of your include statements, or you have a mutual include snarl that needs a forward declaration.

check to see that you included in main first, that is easy enough to fix.
if you did, try moving nave.h to be the top include in the main file.
if that does not work,
add this:

class Nave; to the top of main. This is generally used if you class a uses class b AND class b uses class a, one has to come first, so you tell the compiler that it exists this way.
That often indicates a missing piece of punctuation on a preceding line.
Topic archived. No new replies allowed.