🔒 Closed Ano error mga paps patulong po

Status
Not open for further replies.

RIMURU_tempest300

Eternal Poster
1.
write a program to print the names of the students by creating a student class. If no name is passed while creating an object student class, then the name should be "Unknown", otherwise the name should be equal to the string value passed while creating an object of student class (perform constructor overloading)

PS. first year palang po ako at wala po ako masyado alam dito sa coding


class Student
{
string name;
public;
Student(string s)
{
name = s;
}
Student()
{
name = "Unknown";
}
void print_name()
{
cout << name << endl;
}
};
int main()
{
Student s1("Jojie");
Student s2;
s1.print_name();
s2.print_name();
return 0;
}
}
 
Status
Not open for further replies.

About this Thread

  • 4
    Replies
  • 1K
    Views
  • 4
    Participants
Last reply from:
RIMURU_tempest300

Trending Topics

Online now

Members online
1,102
Guests online
1,742
Total visitors
2,844

Forum statistics

Threads
2,286,663
Posts
29,039,428
Members
1,217,114
Latest member
Tanjiro999
Back
Top