Name : SHASHWAT TIWARI
SEC :- Q2
, 1) Write a program to print the names of students by creating a Student class. If no name is
passed while creating an object of the Student class, then the name should be & quot;
Unknown & quot; , otherwise the name should be equal to the String value passed
while creating the object of the Student class.
CODE:-
#include<iostream>
using namespace std;
class student
{
string name;
int id;
public :
student(string a)
{
name = a;
}
student(int x)
{
name = "unknown";
}
};
int main()
{
student foo{2};
SEC :- Q2
, 1) Write a program to print the names of students by creating a Student class. If no name is
passed while creating an object of the Student class, then the name should be & quot;
Unknown & quot; , otherwise the name should be equal to the String value passed
while creating the object of the Student class.
CODE:-
#include<iostream>
using namespace std;
class student
{
string name;
int id;
public :
student(string a)
{
name = a;
}
student(int x)
{
name = "unknown";
}
};
int main()
{
student foo{2};