Skip to main content
se añadieron 4 caracteres en el cuerpo
Origen Enlace
eferion
  • 52.6k
  • 5
  • 35
  • 75

Quisiera encontrar el error o lo que le falta a mi código para que compile exitosamente.

#include <iostream>
#include <string>
using namespace std;

class Student
{
public:
    string firstName, lastName;
    int dob;
    int phoneNumber;
    int id;
    double overallGPA;
};

int main()
{   
Student Student1;

cout << "\t Student 1 Info:" << endl;
cout << "Student 1 ID: ";
Student1.id = 444444444;

cout << "Student 1 Phone Number: ";
Student1.phoneNumber = {828, 888, 8888};

cout << "Student 1 Date Of Birth: ";
Student1.dob = {11, 21, 1985};

cout << "Student 1 Overall GPA: ";
Student1.overallGPA = 3.45;

cout << "Student 1 First Letter of Last Name: ";
Student1.firstName = "T";

cout << "Student 1 First Letter of First Name: ";
Student1.lastName = "R";


return 0;
}

En las lineas Student1.dobStudent1.dob y Student1.phoneNumberStudent1.phoneNumber son un arreglo, pero no se como manejarlo con las clases.

Me sale el siguiente error en el terminal:

preLab.cpp:30:25: error: expected expression
        Student1.phoneNumber = {828, 888, 8888};
                               ^
preLab.cpp:33:17: error: expected expression
        Student1.dob = {11, 21, 1985};
                       ^
2 errors generated.

Quisiera encontrar el error o lo que le falta a mi código para que compile exitosamente.

#include <iostream>
#include <string>
using namespace std;

class Student
{
public:
    string firstName, lastName;
    int dob;
    int phoneNumber;
    int id;
    double overallGPA;
};

int main()
{   
Student Student1;

cout << "\t Student 1 Info:" << endl;
cout << "Student 1 ID: ";
Student1.id = 444444444;

cout << "Student 1 Phone Number: ";
Student1.phoneNumber = {828, 888, 8888};

cout << "Student 1 Date Of Birth: ";
Student1.dob = {11, 21, 1985};

cout << "Student 1 Overall GPA: ";
Student1.overallGPA = 3.45;

cout << "Student 1 First Letter of Last Name: ";
Student1.firstName = "T";

cout << "Student 1 First Letter of First Name: ";
Student1.lastName = "R";


return 0;
}

En las lineas Student1.dob y Student1.phoneNumber son un arreglo, pero no se como manejarlo con las clases.

Me sale el siguiente error en el terminal:

preLab.cpp:30:25: error: expected expression
        Student1.phoneNumber = {828, 888, 8888};
                               ^
preLab.cpp:33:17: error: expected expression
        Student1.dob = {11, 21, 1985};
                       ^
2 errors generated.

Quisiera encontrar el error o lo que le falta a mi código para que compile exitosamente.

#include <iostream>
#include <string>
using namespace std;

class Student
{
public:
    string firstName, lastName;
    int dob;
    int phoneNumber;
    int id;
    double overallGPA;
};

int main()
{   
Student Student1;

cout << "\t Student 1 Info:" << endl;
cout << "Student 1 ID: ";
Student1.id = 444444444;

cout << "Student 1 Phone Number: ";
Student1.phoneNumber = {828, 888, 8888};

cout << "Student 1 Date Of Birth: ";
Student1.dob = {11, 21, 1985};

cout << "Student 1 Overall GPA: ";
Student1.overallGPA = 3.45;

cout << "Student 1 First Letter of Last Name: ";
Student1.firstName = "T";

cout << "Student 1 First Letter of First Name: ";
Student1.lastName = "R";


return 0;
}

En las lineas Student1.dob y Student1.phoneNumber son un arreglo, pero no se como manejarlo con las clases.

Me sale el siguiente error en el terminal:

preLab.cpp:30:25: error: expected expression
        Student1.phoneNumber = {828, 888, 8888};
                               ^
preLab.cpp:33:17: error: expected expression
        Student1.dob = {11, 21, 1985};
                       ^
2 errors generated.
se eliminaron 13 caracteres en el cuerpo
Origen Enlace
eferion
  • 52.6k
  • 5
  • 35
  • 75

Saludos colegas. Quisiera encontrar el error o lo que le falta a mi codigocódigo para que compile exitosamente.

#include <iostream>
#include <string>
using namespace std;

class Student
{
public:
    string firstName, lastName;
    int dob;
    int phoneNumber;
    int id;
    double overallGPA;
};

int main()
{   
Student Student1;

cout << "\t Student 1 Info:" << endl;
cout << "Student 1 ID: ";
Student1.id = 444444444;

cout << "Student 1 Phone Number: ";
Student1.phoneNumber = {828, 888, 8888};

cout << "Student 1 Date Of Birth: ";
Student1.dob = {11, 21, 1985};

cout << "Student 1 Overall GPA: ";
Student1.overallGPA = 3.45;

cout << "Student 1 First Letter of Last Name: ";
Student1.firstName = "T";

cout << "Student 1 First Letter of First Name: ";
Student1.lastName = "R";


return 0;
}

En las lineas Student1.dob y Student1.phoneNumber son un arreglo, pero no se como manejarlo con las clases.

Me sale el siguiente error en el terminal:

preLab.cpp:30:25: error: expected expression Student1.phoneNumber = {828, 888, 8888}; ^ preLab.cpp:33:17: error: expected expression Student1.dob = {11, 21, 1985}; ^ 2 errors generated.

Gracias por su ayuda.

preLab.cpp:30:25: error: expected expression
        Student1.phoneNumber = {828, 888, 8888};
                               ^
preLab.cpp:33:17: error: expected expression
        Student1.dob = {11, 21, 1985};
                       ^
2 errors generated.

Saludos colegas. Quisiera encontrar el error o lo que le falta a mi codigo para que compile exitosamente.

#include <iostream>
#include <string>
using namespace std;

class Student
{
public:
    string firstName, lastName;
    int dob;
    int phoneNumber;
    int id;
    double overallGPA;
};

int main()
{   
Student Student1;

cout << "\t Student 1 Info:" << endl;
cout << "Student 1 ID: ";
Student1.id = 444444444;

cout << "Student 1 Phone Number: ";
Student1.phoneNumber = {828, 888, 8888};

cout << "Student 1 Date Of Birth: ";
Student1.dob = {11, 21, 1985};

cout << "Student 1 Overall GPA: ";
Student1.overallGPA = 3.45;

cout << "Student 1 First Letter of Last Name: ";
Student1.firstName = "T";

cout << "Student 1 First Letter of First Name: ";
Student1.lastName = "R";


return 0;
}

En las lineas Student1.dob y Student1.phoneNumber son un arreglo, pero no se como manejarlo con las clases.

Me sale el siguiente error en el terminal:

preLab.cpp:30:25: error: expected expression Student1.phoneNumber = {828, 888, 8888}; ^ preLab.cpp:33:17: error: expected expression Student1.dob = {11, 21, 1985}; ^ 2 errors generated.

Gracias por su ayuda.

Quisiera encontrar el error o lo que le falta a mi código para que compile exitosamente.

#include <iostream>
#include <string>
using namespace std;

class Student
{
public:
    string firstName, lastName;
    int dob;
    int phoneNumber;
    int id;
    double overallGPA;
};

int main()
{   
Student Student1;

cout << "\t Student 1 Info:" << endl;
cout << "Student 1 ID: ";
Student1.id = 444444444;

cout << "Student 1 Phone Number: ";
Student1.phoneNumber = {828, 888, 8888};

cout << "Student 1 Date Of Birth: ";
Student1.dob = {11, 21, 1985};

cout << "Student 1 Overall GPA: ";
Student1.overallGPA = 3.45;

cout << "Student 1 First Letter of Last Name: ";
Student1.firstName = "T";

cout << "Student 1 First Letter of First Name: ";
Student1.lastName = "R";


return 0;
}

En las lineas Student1.dob y Student1.phoneNumber son un arreglo, pero no se como manejarlo con las clases.

Me sale el siguiente error en el terminal:

preLab.cpp:30:25: error: expected expression
        Student1.phoneNumber = {828, 888, 8888};
                               ^
preLab.cpp:33:17: error: expected expression
        Student1.dob = {11, 21, 1985};
                       ^
2 errors generated.
Origen Enlace

Clases con "Public Members" ERROR! Expected Expression

Saludos colegas. Quisiera encontrar el error o lo que le falta a mi codigo para que compile exitosamente.

#include <iostream>
#include <string>
using namespace std;

class Student
{
public:
    string firstName, lastName;
    int dob;
    int phoneNumber;
    int id;
    double overallGPA;
};

int main()
{   
Student Student1;

cout << "\t Student 1 Info:" << endl;
cout << "Student 1 ID: ";
Student1.id = 444444444;

cout << "Student 1 Phone Number: ";
Student1.phoneNumber = {828, 888, 8888};

cout << "Student 1 Date Of Birth: ";
Student1.dob = {11, 21, 1985};

cout << "Student 1 Overall GPA: ";
Student1.overallGPA = 3.45;

cout << "Student 1 First Letter of Last Name: ";
Student1.firstName = "T";

cout << "Student 1 First Letter of First Name: ";
Student1.lastName = "R";


return 0;
}

En las lineas Student1.dob y Student1.phoneNumber son un arreglo, pero no se como manejarlo con las clases.

Me sale el siguiente error en el terminal:

preLab.cpp:30:25: error: expected expression Student1.phoneNumber = {828, 888, 8888}; ^ preLab.cpp:33:17: error: expected expression Student1.dob = {11, 21, 1985}; ^ 2 errors generated.

Gracias por su ayuda.