As this is C++ I would use classes instead of structs.. And then just overload the standard operators.
Code:
#include <iostream>
#include <string>
class student
{
private:
student(void){}; // Impossible to create a student without a name
public:
std::string name;
int major;
float gpa;
student(std::string n){name=n;};
student(std::string n, int m){name=n; major=m;};
student(std::string n, int m, float g){name=n; major=m; gpa=g;};
student operator= (student s){
name=s.name;
major=s.major;
gpa=s.gpa;
};
};
std::ostream &operator<<(std::ostream &os, student s){
os << s.name << std::endl;
os << '\t' << s.major << std::endl;
os << '\t' << s.gpa << std::endl;
return os;
};
int main()
{
student s1("felix", 4, 3.9);
student s2 = s1;
std::cout << s1;
std::cout << s2;
return 0;
}