Monday, July 27, 2009

I need c++ code for this problem?

Write a C++ program in which you are required to define a class named Student. The class must include the following two data members.





// data member for Student Name


1: Name





//data member for Student id


2: id





//data member for student email


3: email





Your Program should define three constructors for the class Student





1: a constructor with no parameter


2: a constructor with three parameters (name, id, email)


3: a copy constructor


Your output should be similar to the following





Adnan


Mc002563686


adnan@gmail.com


_________________


Jawad


Bc007004005


jawad@gmail.com


_________________


Salman


mc00500420


salman@gmail.com


_________________





Where;


Adnan


Mc002563686


adnan@gmail.com


are the initialized against the constructor with no parameters.





Jawad


Bc007004005


jawad@gmail.com


are the initialized values against the constructor with three parameters.














Salman


mc00500420


salman@gmail.com





are the initialized values against the copy constructor that copies the values of already existed obje

I need c++ code for this problem?
You can't really expect us to do all the work for you. I will show you what your Student.h file should look like. That'll give you enough of a head start to get this thing done.





#include %26lt;string%26gt;


#include %26lt;iostream%26gt;





using namespace std;





class Student


{


public:





Student() { } // Default constructor


// Full constructor


Student(const string%26amp; name, const string%26amp; id, const string%26amp; email) :


name_(name), id_(id), email_(email) { }


Student(const Student%26amp;); // Copy constructor


~Student() { } // Destructor


void operator=(const Student%26amp;);


bool operator==(const Student%26amp;);


inline string name() { return name_; }


inline string id() { return id_; }


inline string email() { return email_; }


private:


string name_;


string id_;


string email_;


};





ostream %26amp;operator%26lt;%26lt;(ostream%26amp; os, const Student%26amp; s) {


//


// Insert student info into ostream


//





return os;


}


No comments:

Post a Comment