Lab 03 Manual
Lab 03 Manual
• Submit the file with your names following your registration numbers like AI001_Name.
• Submit soft copy of the report before deadline. Marks will be deducted for late
submissions.
Theory
Example
#include <iostream>
class Sample {
private:
int value;
public:
Sample(int v) : value(v) {}
void show() const { // Constant function
value = v;
};
int main() {
Sample obj(10);
obj.show();
obj.setValue(20);
obj.show();
return 0;
Theory
Example:
#include <iostream>
private:
string name;
public:
cout << "Roll No: " << rollNo << ", Name: " << name << endl;
};
int main() {
s1.show();
return 0;
Theory
Example:
#include <iostream>
private:
double balance;
public:
BankAccount(double b) : balance(b) {}
balance += amount;
return balance;
};
int main() {
BankAccount account(500.0);
account.deposit(200);
return 0;