Student Name Class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gneisler
    New Member
    • May 2013
    • 9

    Student Name Class

    I am new to C++ and in need of assistance with this program.
    I can not get this program to display "Name for student1 is unassigned and ssn is 999999999" and to display next "Name for student2 is John Doe and ssn is 123456789". Thank you, for your help.

    Code:
    #include <iostream>
    #include <iomanip>
    #include <string>
    
    
    using namespace std;
    
    class Student
    {
    	private:
    		
    		char name[80]; // Student Name
    		int SSN;      // Social Sercurity Number (SNN)
    		
    	public:	
    	
    	    student();
    	    student(char name[80],int SNN);
    	    void setstudent(char name[80]= unassigned,int SNN = 999999999); 
    	    int setSSN;     // should not accept 1 argument and update
    	    int getSSN();  // getSSN should return the class SSN
    	    void char setname();
    	    void char getname();
    	    void display();
    };
    
    Student :: Student()
    {
    	Name = "Unassigned"; // A Default constructor
    	SSN = 999999999;    // A Default constructor
    	
    }
    
    Student :: Student(char Name[80],int SSN) 
    {
    	Name = "John Doe"; // Student Name
    	SSN = 123456789;   // // Social Sercurity Number (SNN)
    	
    }
    
    char Student :: getname()
    {
    	return name;
    }
    
    int Student :: getSSN()
    {
    	return SSN;
    }
    
    void Student :: display ()
    {
    	
    	cout<<"Name for Student 1 is"<<name1<<"and"<<SSN1<<endl;
    	cout<<"Name for Student 2 is"<<name2<<"and"<<SSN2<<endl;
    	
    }
    
    int main ()
    {
    	
    	int SSN1,SSN2;
    	char name1, name2;
    	display();
    	
    	return 0;
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    There are many things not correct in your class design, but that's a topic for a later day.

    The main thing I see is that a student object is never created in main() so nothing ever executes.

    Plus main() has a display function that has no code.

    Post again if you are still stuck.

    Comment

    • gneisler
      New Member
      • May 2013
      • 9

      #3
      weaknessforcats ,

      Thank you for your help.

      Comment

      Working...