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
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
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 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 Rectangle
{
double length;
double width;
public:
Rectangle()
{
cout
Click here to claim your Sponsored Listing.
Category
Address
Lahore