Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
58 views
in Technique[技术] by (71.8m points)

c++ - Error 'string' in class 'Empleado' does not have a type

I keep getting the error that string in my class Empleado does not have a name type, I looked up one solution, which was to add the header #include string but I still have the same error. This is my Empleado.ccp code. One thing to note is that this is a subclass of another class called Persona.

#include "Empleado.h"
#include <string>
#include <iostream>
using namespace std;


Empleado::Empleado(int edad, string nombre, float altura, string emp, string puesto):
    Persona( edad,  nombre,  altura)
{
    numEmpleado=emp;
    puesto=puesto;
}

Empleado :: string getNumEmpleado()
{
    return numEmpleado;
}

Empleado :: string getPuesto()
{
    return puesto;
}   

Empleado :: void setNumEmpleado(string num)
{
    numEmpleado=num;
}
Empleado :: void setPuesto(string puesto)
{
    puesto=puesto;  
}
question from:https://stackoverflow.com/questions/65839123/error-string-in-class-empleado-does-not-have-a-type

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have the function return types in the wrong place on all your function signatures. It belongs on the left before the full name of the function.

string Empleado::getNumEmpleado()

string Empleado::getPuesto()

void Empleado::setNumEmpleado(string num)

void Empleado::setPuesto(string puesto)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...