Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

Object Oriented Programming second assignment fall 2009 Solution 2nd

#include
#include

//class definition
class student
{
//hidden part
private:
char* name; //for student's name
char* id; //for id
char* email; // for email

//interface
public:
//paramterless constructor
student()
{
name="Adnan";
id="Mc002563686";
email="help@vuhelp.com";
}
//parameterized constructor
student(char* name1, char* id1, char* email1)
{
name = name1;
id = id1;
email = email1;
}
//copy constructor
student(const student &other)
{
//for string lengths
int length1, length2, length3;
length1 = strlen(other. name);
length2 = strlen(other. id);
length3 = strlen(other. email);
//allocating new memory space
name = new char[length1 + 1];
id = new char[length2 + 1];
email = new char[length3+1];
//copying strings
strcpy( name, other.name );
strcpy( id, other.id );
strcpy( email, other.email);
}
//for displaying name, id and email address
void display()
{
cout<"_________________"<}

//destructor
~student(){}
};

//main function
int main(){
//object declarations
student s1;
student s2("aby", "rollno", "aby.javapk@gmail.com");
student s3(s2);
//display function calls
s1.display();
s2.display();
s3.display();

}



This code 4 your help not as it Copy and paste .U get zero mark.....BEST OF LUCK

Views: 55

Reply to This

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service