domingo, 22 de febrero de 2015

Apuntar Objetos a Funciones Visual C++


 
#include <cstdlib>
#include <iostream>

using namespace std;

class Student
{
public:
 int semesterHours;
 double gpa;
};

void someFn( Student *pS )
{
 pS -> semesterHours = 10;
 pS -> gpa = 3.0;
 cout << "El valor de pS -> gpa es: " << pS -> gpa << endl;
}

int main( int argc , char *argv[] )
{
 Student s;
 s.gpa = 0.0;

 cout << "El valor de s.gpa es: " << s.gpa << endl;

 someFn( &s );

 cout << "El valor de s.gpa es: " << s.gpa << endl;

 system("pause");
 return 0;
}

No hay comentarios:

Publicar un comentario