Lets Code ittt
Page to help Students to learn easily programming
21/08/2023
using namespace std;
class Laptop
{
private:
int static count;
int static count_destroy;
int RAM;
int Generation;
public:
Laptop()
{
count++;
RAM = 0;
Generation = 0;
}
Laptop(int RAM, int Generation) :RAM(RAM), Generation(Generation)
{
count++;
}
static int getcount()
{
return count;
}
static int getcount_destroy()
{
return count_destroy;
}
~Laptop()
{
count_destroy++;
}
};
int Laptop::count = 0;
int Laptop::count_destroy = 0;
int main()
{
Laptop No1;//object for default constructor
Laptop No2;
{
Laptop No3(3, 3);//this object will be destroyed
} //three objects have been created
cout
19/08/2023
using namespace std;
class Box {
private:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
public:
static int objectCount;
// Overloaded Constructor
Box(double l = 2.0, double b = 2.0, double h = 2.0) {
cout
07/08/2023
using namespace std;
class Student {
private:
int id;
string name;
int oopMarks;
int calculusMarks;
int dsMarks;
public:
// Default constructor
Student() : id(0), name(""), oopMarks(0), calculusMarks(0), dsMarks(0) //member initilization method
{
}
// Parameterized constructor
Student(int id, const string& name, int oopMarks, int calculusMarks, int dsMarks)
: id(id), name(name), oopMarks(oopMarks), calculusMarks(calculusMarks), dsMarks(dsMarks)
{
}
//Copy Constructor
Student(const Student& o)
{
setId(o.id);
setName(o.name);
setOopMarks(o.oopMarks);
setCalculusMarks(o.calculusMarks);
setDsMarks(o.dsMarks);
}
// Getter and Setter for id
int getId() const {
return id;
}
void setId(int newId) {
if (id >= 0)
{
id = newId;
}
else
{
cerr
03/08/2023
using namespace std;
class BankAccount {
private:
// Private data members
int accountNo;
string name;
string cnic;
string phNo;
string address;
double balance;
public:
// Constructors
BankAccount()
{
accountNo = 0;
name="";
cnic="";
phNo="";
address="";
balance=0.0;
}
BankAccount(int accNo, string n, string c, string ph, string addr, double bal)
{
setAccountNo(accNo);
setName(n);
setCNIC(c);
setPhNo(ph);
setAddress(addr);
setBalance(bal);
}
// Deep copy constructor
BankAccount(const BankAccount& other)
{
accountNo=other.accountNo;
name=other.name;
cnic=other.cnic;
phNo=other.phNo;
address=other.address;
balance=other.balance;
}
// Setters
void setAccountNo(int accNo) {
accountNo = accNo;
}
void setName( string n) {
name = n;
}
void setCNIC( string c) {
cnic = c;
}
void setPhNo( string ph) {
phNo = ph;
}
void setAddress( string addr) {
address = addr;
}
void setBalance(double bal) {
balance = bal;
}
// Print function
void printAccountInfo() const {
cout
03/08/2023
using namespace std;
class StudentResultSheet {
string name;
int id;
int marks;
public:
StudentResultSheet() {
name = "";
id = 0;
marks = 0;
}
void read() {
cout id;
cout > marks;
cin.ignore(); // to clear the newline character from the input buffer
}
string get_name() {
return name;
}
int get_id() {
return id;
}
int get_marks() {
return marks;
}
};
int main() {
StudentResultSheet students[10];
for (int i = 0; i < 10; i++) {
cout
29/07/2023
using namespace std;
class BankAccount {
private:
string name;
int age;
string profession;
double accountNumber;
double currentBalance;
public:
void setName(const string& name) {
this->name = name;
}
void setAge(int age) {
this->age = age;
}
void setProfession(const string& profession) {
this->profession = profession;
}
void setAccountNumber(double accountNumber) {
if (accountNumber >= 10001 && accountNumber accountNumber = accountNumber;
}
else {
while (!(accountNumber >= 10001 && accountNumber accountNumber;
}
this->accountNumber = accountNumber;
}
}
void setCurrentBalance(double currentBalance) {
if (currentBalance >= 500) {
this->currentBalance = currentBalance;
}
else {
cerr
28/07/2023
using namespace std;
class Person {
private:
string name;
int age;
public:
void setName(string name) {
this->name = name;
}
void setAge(int age)
{
if (age >= 0 && age age = age;
}
else
{
cerr age;
}
this->age = age;
}
}
string getName()
{
return name;
}
int getAge()
{
return age;
}
void display()
{
cout
28/07/2023
using namespace std;
class Car {
string brand;
string model;
public:
Car(string brand, string model) {
this->brand = brand;
this->model = model;
}
//Copy Constructor
Car(Car& other) {
this->brand = other.brand;
this->model = other.model;
}
void display()
{
cout
28/07/2023
using namespace std;
class Date {
private:
int month;
int day;
int year;
public:
Date()
{
month = 1;
day = 1;
year = 2000;
}
Date(int m, int d, int y)
{
month=m;
day=d;
year=y;
}
void display()
{
cout
27/07/2023
using namespace std;
class Time {
private:
int hour;
int minute;
int second;
public:
// Default constructor
Time() {
hour = 0;
minute = 0;
second = 0;
}
// Overloaded constructor
Time(int h, int m, int s) {
hour = h;
minute = m;
second = s;
}
//function to show hour,minutes and seconds
void calculate_display_time() {
cout
27/07/2023
using namespace std;
class Rectangle
{
double length;
double width;
public:
Rectangle()
{
cout
27/07/2023
using namespace std;
class Exam
{
int exam_id;
int obtained_marks;
int total_marks;
public:
Exam()
{
cout
Click here to claim your Sponsored Listing.
Category
Address
Lahore