-1

It doesn't accept my string and variables just in that part and I don't know why, I can't properly make my variables in the void part like matricula=_matricula because it doesn't detect it and says its undefined

#include <iostream>


using namespace std;

class Alumnos{
    private:
        string matricula;
        string nombre;
        int edad;
        string carrera;
        
    public:
        Alumnos();
        void setAlumnos(string,string,int,string);
        string getAlumnoMatricula();
        string getAlumnoNombre();
        int getAlumnoEdad();
        string getAlumnoCarrera();
};
Alumnos::Alumnos(){  
}
void Alumnos::setAlumnos(string_matricula,string_nombre,int_edad,string_carrera){
    matricula=_matricula;
    nombre=_nombre;
    edad=_edad;
    carrera=_carrera;
}
/////////
string Alumnos::getAlumnoMatricula(){
    return matricula;
}
string Alumnos::getAlumnoNombre(){
    return nombre;
}
int Alumnos::getAlumnoEdad(){
    return edad;
}
string Alumnos::getAlumnoCarrera(){
    return carrera;
}
////////
string main(){
    string alumnoMatricula,alumnoNombre,alumnoEdad,alumnoCarrera;
    Alumnos cl;
    cl.setAlumnos(A01643364,Sebastian,18,ITC);
    alumnoMatricula=cl.getAlumnoMatricula();
    alumnoNombre=cl.getAlumnoNombre();
    alumnoEdad=cl.getAlumnoEdad();
    alumnoCarrera=cl.getAlumnoCarrera();
    cout<<"La matricula del almuno es: "<<alumnoMatricula<<", su nombre es"<<alumnoNombre<<", su edad es"<<alumnoEdad<<"y su carrera es: "<<alumnoCarrera<<endl;
}
drescherjm
  • 10,365
  • 5
  • 44
  • 64
Sebastian
  • 1
  • 2
  • 3
    `string main(){` is not valid. There are 2 valid main signatures: [https://stackoverflow.com/questions/4207134/what-is-the-proper-declaration-of-main-in-c](https://stackoverflow.com/questions/4207134/what-is-the-proper-declaration-of-main-in-c) – drescherjm Nov 24 '22 at 03:10
  • 1
    Hello, can you please avoid tag-spamming. You tagged C++ _AND_ three individual language standards. Your program has nothing to do with any of those. You're not asking about any language features particular to one standard. In fact, your code does not even require C++11. It is quite ordinary beginner-level C++. So, in future, know that people who are following C++ will see your question if you tag it that way. I will remove the inappropriate tags. Happy coding. – paddy Nov 24 '22 at 03:12
  • 2
    You must have at least one character of whitespace between a type name and an identifier. _i.e._ `string _matricula`, not `string_matricula` _etc_... – paddy Nov 24 '22 at 03:15
  • Starting a question with the word "It" is a sign that more thought should go into writing the question, that the author unfairly expects readers to read the author's mind to know the context. – JaMiT Nov 24 '22 at 03:41

1 Answers1

2

You have missed spaces in the arguments (not string_matricula, it is string _matricula). Also while passing the arguments pass them as string inside " ". And main must return only int, it cannot return string.

#include <iostream>
using namespace std;

class Alumnos{
    private:
        string matricula;
        string nombre;
        int edad;
        string carrera;
        
    public:
        Alumnos();
        void setAlumnos(string,string,int,string);
        string getAlumnoMatricula();
        string getAlumnoNombre();
        int getAlumnoEdad();
        string getAlumnoCarrera();
};
Alumnos::Alumnos(){  
}
void Alumnos::setAlumnos(string _matricula,string _nombre,int _edad,string _carrera){
    matricula=_matricula;
    nombre=_nombre;
    edad=_edad;
    carrera=_carrera;
}
/////////
string Alumnos::getAlumnoMatricula(){
    return matricula;
}
string Alumnos::getAlumnoNombre(){
    return nombre;
}
int Alumnos::getAlumnoEdad(){
    return edad;
}
string Alumnos::getAlumnoCarrera(){
    return carrera;
}
////////
int main(){
    string alumnoMatricula,alumnoNombre,alumnoEdad,alumnoCarrera;
    Alumnos cl;
    cl.setAlumnos("A01643364","Sebastian",18,"ITC");
    alumnoMatricula=cl.getAlumnoMatricula();
    alumnoNombre=cl.getAlumnoNombre();
    alumnoEdad=cl.getAlumnoEdad();
    alumnoCarrera=cl.getAlumnoCarrera();
    cout<<"La matricula del almuno es: "<<alumnoMatricula<<", su nombre es"<<alumnoNombre<<", su edad es"<<alumnoEdad<<"y su carrera es: "<<alumnoCarrera<<endl;
}