Untitled document
Untitled document
class Employee {
private:
int emp_id;
string name;
string address;
public:
// Function to accept employee details
void accept() {
cout << "Enter Employee ID: ";
cin >> emp_id;
cin.ignore(); // Ignore newline character
int main() {
Employee emp[3]; // Array of 3 Employee objects
return 0;
}
#include <iostream>
using namespace std;
class Rectangle {
private:
float length, breadth;
public:
// Default constructor initializing length and breadth
Rectangle() {
length = 5.0; // Default length
breadth = 3.0; // Default breadth
}
int main() {
Rectangle rect; // Object created using default constructor
rect.display(); // Display area
return 0;
}
#include <iostream>
using namespace std;
class Circle {
private:
float radius;
public:
// Parameterized constructor
Circle(float r) {
radius = r;
}
int main() {
float r;
cout << "Enter radius of the circle: ";
cin >> r;
return 0;
}
#include <iostream>
using namespace std;
class Student {
private:
int stud_id;
string name;
float marks;
public:
// Function to accept student details
void accept() {
cout << "Enter Student ID: ";
cin >> stud_id;
cin.ignore(); // Ignore newline character
int main() {
Student stud[2]; // Array of 2 Student objects
return 0;
}