trash / index.html
dkescape's picture
Update index.html
c6ee7d7 verified
raw
history blame
28 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>C++ Exam Cheat Sheet - OOP</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#2563eb',
secondary: '#f59e0b',
tertiary: '#10b981',
dark: '#1e293b',
light: '#f8fafc'
}
}
}
}
</script>
<style>
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Poppins:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Poppins', sans-serif;
background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
color: #1e293b;
}
h1, h2, h3 {
font-family: 'Poppins', sans-serif;
font-weight: 700;
}
.code-font {
font-family: 'JetBrains Mono', monospace;
}
.header-gradient {
background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}
.unit-card {
transition: transform 0.3s ease, box-shadow 0.3s ease;
border-radius: 16px;
overflow: hidden;
border: none;
}
.unit-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.unit-1 { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }
.unit-2 { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.unit-3 { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.code-block {
background: #1e293b;
border-radius: 12px;
padding: 1.5rem;
position: relative;
overflow-x: auto;
}
.code-block::before {
content: '';
position: absolute;
top: 12px;
left: 12px;
width: 12px;
height: 12px;
background: #ef4444;
border-radius: 50%;
box-shadow: 20px 0 0 #f59e0b, 40px 0 0 #10b981;
}
.tip-card {
border-left: 4px solid #f59e0b;
background: rgba(245, 158, 11, 0.1);
}
.tip-card i {
color: #f59e0b;
}
.table-container {
overflow-x: auto;
}
.highlight {
background: linear-gradient(120deg, rgba(251, 191, 36, 0.3) 0%, rgba(251, 191, 36, 0) 100%);
padding: 0.2rem 0.4rem;
border-radius: 4px;
font-weight: 600;
}
.key-point {
background: rgba(37, 99, 235, 0.1);
border-radius: 8px;
padding: 1.5rem;
}
.concept-pill {
background: rgba(37, 99, 235, 0.1);
padding: 0.5rem 1rem;
border-radius: 9999px;
font-weight: 600;
display: inline-flex;
align-items: center;
gap: 0.5rem;
}
.badge {
padding: 0.25rem 0.75rem;
border-radius: 9999px;
font-weight: 600;
font-size: 0.75rem;
}
@media (max-width: 768px) {
.header-content {
flex-direction: column;
text-align: center;
}
}
</style>
</head>
<body class="min-h-screen py-8 px-4 sm:px-6 lg:px-8">
<div class="max-w-6xl mx-auto">
<!-- Header -->
<header class="header-gradient text-white rounded-2xl shadow-xl mb-12 overflow-hidden">
<div class="p-8 md:p-12">
<div class="flex flex-col md:flex-row items-center justify-between gap-6 header-content">
<div class="flex items-center gap-4">
<div class="bg-white/20 p-4 rounded-xl">
<i class="fas fa-file-code text-4xl"></i>
</div>
<div>
<h1 class="text-3xl md:text-4xl font-bold">C++ Exam Cheat Sheet (1-Page)</h1>
<div class="mt-2 flex flex-wrap gap-2">
<span class="badge bg-white/20">OOP</span>
<span class="badge bg-white/20">C++</span>
<span class="badge bg-white/20">Exam Prep</span>
</div>
</div>
</div>
<div class="text-center md:text-right">
<p class="text-lg font-medium"><i class="fas fa-book mr-2"></i>Subject: Object-Oriented Programming with C++</p>
<p class="text-lg mt-1"><i class="fas fa-user-graduate mr-2"></i>For: Diploma in Computer Engineering (2nd Year)</p>
<p class="text-lg mt-1"><i class="fas fa-database mr-2"></i>Based on: Official Question Bank (Units 1–3)</p>
</div>
</div>
</div>
</header>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Unit 1 -->
<div class="unit-card bg-white shadow-lg">
<div class="unit-1 text-white p-6">
<h2 class="text-2xl font-bold flex items-center gap-2">
<i class="fas fa-cube"></i> UNIT 1: Principles of OOP
</h2>
</div>
<div class="p-6">
<!-- OOP Definition -->
<div class="mb-8">
<div class="flex items-center gap-2 mb-4">
<h3 class="text-xl font-bold text-primary">OOP Definition (2 marks)</h3>
<span class="badge bg-primary/20 text-primary">Key Concept</span>
</div>
<div class="bg-blue-50 p-4 rounded-lg border-l-4 border-primary mb-4">
<p class="font-medium">
<span class="highlight">OOP</span> = Object-Oriented Programming. It uses
<span class="highlight">objects</span> (instances of classes) to model real-world entities.
Focuses on <span class="highlight">data security, reusability, and modularity</span>.
</p>
</div>
<div class="mt-4">
<h4 class="font-bold text-lg text-dark mb-2">Core Concepts (Remember A PIE):</h4>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
<div class="concept-pill text-primary">
<i class="fas fa-eye-slash"></i> <span class="font-bold">A</span>bstracton β†’ Hide internal details
</div>
<div class="concept-pill text-primary">
<i class="fas fa-shapes"></i> <span class="font-bold">P</span>olymorphism β†’ One name, many forms
</div>
<div class="concept-pill text-primary">
<i class="fas fa-sitemap"></i> <span class="font-bold">I</span>nheritance β†’ Reuse parent class
</div>
<div class="concept-pill text-primary">
<i class="fas fa-box"></i> <span class="font-bold">E</span>ncapsulation β†’ Bind data + functions
</div>
</div>
</div>
</div>
<!-- OOP vs POP -->
<div class="mb-8">
<h3 class="text-xl font-bold text-primary mb-4">OOP vs POP (3 marks)</h3>
<div class="table-container">
<table class="min-w-full divide-y divide-gray-200 border border-gray-200 rounded-lg overflow-hidden">
<thead class="bg-primary/10">
<tr>
<th class="px-4 py-3 text-left font-medium text-dark">Feature</th>
<th class="px-4 py-3 text-left font-medium text-dark">OOP</th>
<th class="px-4 py-3 text-left font-medium text-dark">POP</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
<tr class="hover:bg-gray-50">
<td class="px-4 py-3 font-medium">Approach</td>
<td class="px-4 py-3">Bottom-up</td>
<td class="px-4 py-3">Top-down</td>
</tr>
<tr class="hover:bg-gray-50">
<td class="px-4 py-3 font-medium">Data & Functions</td>
<td class="px-4 py-3">Combined (in objects)</td>
<td class="px-4 py-3">Separate</td>
</tr>
<tr class="hover:bg-gray-50">
<td class="px-4 py-3 font-medium">Inheritance</td>
<td class="px-4 py-3 text-green-600"><i class="fas fa-check-circle mr-1"></i> Yes</td>
<td class="px-4 py-3 text-red-600"><i class="fas fa-times-circle mr-1"></i> No</td>
</tr>
<tr class="hover:bg-gray-50">
<td class="px-4 py-3 font-medium">Access Control</td>
<td class="px-4 py-3 text-green-600"><i class="fas fa-check-circle mr-1"></i> (public/private)</td>
<td class="px-4 py-3 text-red-600"><i class="fas fa-times-circle mr-1"></i> No</td>
</tr>
<tr class="hover:bg-gray-50">
<td class="px-4 py-3 font-medium">Examples</td>
<td class="px-4 py-3">C++, Java</td>
<td class="px-4 py-3">C, BASIC</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Access Specifiers -->
<div class="mb-8">
<h3 class="text-xl font-bold text-primary mb-4">Access Specifiers (3–4 marks)</h3>
<div class="table-container">
<table class="min-w-full divide-y divide-gray-200 border border-gray-200 rounded-lg overflow-hidden">
<thead class="bg-primary/10">
<tr>
<th class="px-4 py-3 text-left font-medium text-dark">Specifier</th>
<th class="px-4 py-3 text-left font-medium text-dark">Access</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
<tr class="hover:bg-gray-50">
<td class="px-4 py-3 font-medium"><code>public</code></td>
<td class="px-4 py-3">Anywhere</td>
</tr>
<tr class="hover:bg-gray-50">
<td class="px-4 py-3 font-medium"><code>private</code></td>
<td class="px-4 py-3">Only in class</td>
</tr>
<tr class="hover:bg-gray-50">
<td class="px-4 py-3 font-medium"><code>protected</code></td>
<td class="px-4 py-3">In class & derived classes</td>
</tr>
</tbody>
</table>
</div>
<div class="mt-4 bg-yellow-50 p-4 rounded-lg border-l-4 border-yellow-500">
<p class="font-medium text-dark">
<i class="fas fa-exclamation-circle text-yellow-500 mr-2"></i>
<code>private</code> members <span class="font-bold">cannot be accessed in <code>main()</code></span>.
</p>
</div>
</div>
<!-- Scope Resolution Operator -->
<div>
<h3 class="text-xl font-bold text-primary mb-4">Scope Resolution Operator (::) (3 marks)</h3>
<p class="mb-4">Used to:</p>
<ol class="list-decimal list-inside mb-4 space-y-2">
<li>Access <span class="highlight">global variable</span> when local has same name</li>
<li>Define <span class="highlight">member functions outside class</span></li>
</ol>
<div class="code-block">
<pre class="text-green-400 code-font"><code>int x = 10;
int main() {
int x = 20;
cout &lt;&lt; ::x; // prints 10
}</code></pre>
</div>
</div>
</div>
</div>
<!-- Unit 2 -->
<div class="unit-card bg-white shadow-lg">
<div class="unit-2 text-white p-6">
<h2 class="text-2xl font-bold flex items-center gap-2">
<i class="fas fa-functions"></i> UNIT 2: Functions, Classes & Objects
</h2>
</div>
<div class="p-6">
<!-- Inline Function -->
<div class="mb-8">
<h3 class="text-xl font-bold text-secondary mb-4">Inline Function (3–4 marks)</h3>
<div class="bg-amber-50 p-4 rounded-lg border-l-4 border-secondary mb-4">
<p class="font-medium">
Function expanded at compile time for speed. Use <code class="highlight">inline</code> keyword.
</p>
</div>
<div class="code-block">
<pre class="text-green-400 code-font"><code>inline int cube(int a) {
return a * a * a;
}</code></pre>
</div>
<div class="mt-4 bg-yellow-50 p-4 rounded-lg border-l-4 border-yellow-500">
<p class="font-medium text-dark">
<i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
Use for <span class="font-bold">short, frequently called functions</span>.
</p>
</div>
</div>
<!-- Function Overloading -->
<div class="mb-8">
<h3 class="text-xl font-bold text-secondary mb-4">Function Overloading (3–4 marks)</h3>
<div class="bg-amber-50 p-4 rounded-lg border-l-4 border-secondary mb-4">
<p class="font-medium">
Same name, <span class="highlight">different parameters</span> (number or type).
<span class="font-bold">Not by return type</span>.
</p>
</div>
<div class="code-block">
<pre class="text-green-400 code-font"><code>class Cal {
public:
int add(int a, int b) { return a+b; }
int add(int a, int b, int c) { return a+b+c; }
};</code></pre>
</div>
</div>
<!-- Friend Function -->
<div class="mb-8">
<h3 class="text-xl font-bold text-secondary mb-4">Friend Function (3 marks)</h3>
<div class="bg-amber-50 p-4 rounded-lg border-l-4 border-secondary mb-4">
<p class="font-medium">
Non-member function that can access <code>private</code> members using <code>friend</code>.
</p>
</div>
<div class="code-block">
<pre class="text-green-400 code-font"><code>class Test {
int a;
public:
friend void show(Test t);
};
void show(Test t) {
cout &lt;&lt; t.a; // OK!
}</code></pre>
</div>
</div>
<!-- Class & Object -->
<div>
<h3 class="text-xl font-bold text-secondary mb-4">Class & Object (2 marks)</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="key-point">
<h4 class="font-bold text-lg text-secondary mb-2 flex items-center gap-2">
<i class="fas fa-blueprint"></i> Class
</h4>
<p>Blueprint (<code class="bg-secondary/10 p-1 rounded">class Student {};</code>)</p>
</div>
<div class="key-point">
<h4 class="font-bold text-lg text-secondary mb-2 flex items-center gap-2">
<i class="fas fa-cube"></i> Object
</h4>
<p>Instance (<code class="bg-secondary/10 p-1 rounded">Student s1;</code>)</p>
</div>
</div>
<div class="mt-4 bg-yellow-50 p-4 rounded-lg border-l-4 border-yellow-500">
<p class="font-medium text-dark">
<i class="fas fa-info-circle text-yellow-500 mr-2"></i>
An <span class="font-bold">instance of a class</span> = object created at runtime.
</p>
</div>
</div>
</div>
</div>
<!-- Unit 3 -->
<div class="unit-card bg-white shadow-lg">
<div class="unit-3 text-white p-6">
<h2 class="text-2xl font-bold flex items-center gap-2">
<i class="fas fa-tools"></i> UNIT 3: Constructor & Destructor
</h2>
</div>
<div class="p-6">
<!-- Constructor -->
<div class="mb-8">
<h3 class="text-xl font-bold text-tertiary mb-4">Constructor (3 marks)</h3>
<div class="bg-emerald-50 p-4 rounded-lg border-l-4 border-tertiary mb-4">
<p class="font-medium">
Special function with <span class="highlight">same name as class</span>, called
<span class="highlight">automatically</span> when object is created.
<span class="font-bold">No return type</span>.
</p>
</div>
<div>
<h4 class="font-bold text-lg text-dark mb-3">Types:</h4>
<div class="space-y-3">
<div class="flex items-start gap-3">
<div class="bg-tertiary text-white rounded-full h-6 w-6 flex items-center justify-center mt-1 flex-shrink-0">1</div>
<div>
<span class="font-bold">Default</span> β†’ No parameters
</div>
</div>
<div class="flex items-start gap-3">
<div class="bg-tertiary text-white rounded-full h-6 w-6 flex items-center justify-center mt-1 flex-shrink-0">2</div>
<div>
<span class="font-bold">Parameterized</span> β†’ Takes parameters
</div>
</div>
<div class="flex items-start gap-3">
<div class="bg-tertiary text-white rounded-full h-6 w-6 flex items-center justify-center mt-1 flex-shrink-0">3</div>
<div>
<span class="font-bold">Copy</span> β†’ Initializes using another object
</div>
</div>
</div>
</div>
</div>
<!-- Parameterized Constructor -->
<div class="mb-8">
<h3 class="text-xl font-bold text-tertiary mb-4">Parameterized Constructor (3–4 marks)</h3>
<div class="code-block">
<pre class="text-green-400 code-font"><code>class Student {
public:
int id;
string name;
Student(int i, string n) {
id = i;
name = n;
}
};
// Usage: Student s(101, "Rahul");</code></pre>
</div>
</div>
<!-- Program: Student Details -->
<div>
<h3 class="text-xl font-bold text-tertiary mb-4">Program: Student Details (3 marks)</h3>
<div class="code-block">
<pre class="text-green-400 code-font"><code>#include &lt;iostream&gt;
using namespace std;
class Student {
public:
int id;
string name;
float salary;
Student(int i, string n, float s) {
id = i;
name = n;
salary = s;
}
void display() {
cout &lt;&lt; id &lt;&lt; " " &lt;&lt; name &lt;&lt; " " &lt;&lt; salary &lt;&lt; endl;
}
};
int main() {
Student s1(101, "Rahul", 50000);
s1.display();
return 0;
}</code></pre>
</div>
<div class="mt-4 bg-emerald-50 p-4 rounded-lg border-l-4 border-emerald-500">
<p class="font-medium text-dark">
<i class="fas fa-pen-alt text-emerald-500 mr-2"></i>
<span class="font-bold">Write this in exam</span> β€” covers Q25, Q27, and constructor use.
</p>
</div>
</div>
</div>
</div>
</div>
<!-- Quick Tips Section -->
<div class="mt-12 bg-white rounded-2xl shadow-lg overflow-hidden">
<div class="bg-gradient-to-r from-primary to-secondary p-6">
<h2 class="text-2xl font-bold text-white flex items-center gap-3">
<i class="fas fa-lightbulb"></i> Quick Tips for Exam
</h2>
</div>
<div class="p-6 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<div class="tip-card p-5 rounded-lg flex items-start gap-3">
<i class="fas fa-pen text-2xl mt-1"></i>
<div>
<h3 class="font-bold text-lg text-dark mb-2">Write Neatly & Underline</h3>
<p>Underline keywords: <code class="bg-primary/10 p-1 rounded">private</code>,
<code class="bg-primary/10 p-1 rounded">friend</code>,
<code class="bg-primary/10 p-1 rounded">inline</code>,
<code class="bg-primary/10 p-1 rounded">::</code></p>
</div>
</div>
<div class="tip-card p-5 rounded-lg flex items-start gap-3">
<i class="fas fa-table text-2xl mt-1"></i>
<div>
<h3 class="font-bold text-lg text-dark mb-2">Draw Tables</h3>
<p>For comparisons (OOP vs POP, access specifiers) to organize information clearly.</p>
</div>
</div>
<div class="tip-card p-5 rounded-lg flex items-start gap-3">
<i class="fas fa-code text-2xl mt-1"></i>
<div>
<h3 class="font-bold text-lg text-dark mb-2">Write Small Code</h3>
<p>Even 4 lines with comments = full marks. Focus on key concepts.</p>
</div>
</div>
<div class="tip-card p-5 rounded-lg flex items-start gap-3">
<i class="fas fa-hourglass-half text-2xl mt-1"></i>
<div>
<h3 class="font-bold text-lg text-dark mb-2">Time Management</h3>
<p>Spend 1 min per 2 marks β€” don't over-write answers.</p>
</div>
</div>
<div class="tip-card p-5 rounded-lg flex items-start gap-3">
<i class="fas fa-exclamation-triangle text-2xl mt-1"></i>
<div>
<h3 class="font-bold text-lg text-dark mb-2">Don't Leave Blanks</h3>
<p>If blank, write something β€” definition, syntax, or example.</p>
</div>
</div>
<div class="tip-card p-5 rounded-lg flex items-start gap-3">
<i class="fas fa-check-circle text-2xl mt-1"></i>
<div>
<h3 class="font-bold text-lg text-dark mb-2">Review Core Concepts</h3>
<p>Focus on A PIE (Abstraction, Polymorphism, Inheritance, Encapsulation).</p>
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer class="mt-12 text-center text-gray-600">
<p class="mb-2">C++ Exam Cheat Sheet - Diploma in Computer Engineering (2nd Year)</p>
<p>Based on Official Question Bank - Units 1–3</p>
<div class="mt-4 flex justify-center gap-4">
<a href="#" class="text-primary hover:text-primary/80"><i class="fab fa-github"></i></a>
<a href="#" class="text-primary hover:text-primary/80"><i class="fab fa-linkedin"></i></a>
<a href="#" class="text-primary hover:text-primary/80"><i class="fas fa-envelope"></i></a>
</div>
</footer>
</div>
</body>
</html>