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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>C++ Exam Cheat Sheet - OOP</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<script>
|
| 10 |
+
tailwind.config = {
|
| 11 |
+
theme: {
|
| 12 |
+
extend: {
|
| 13 |
+
colors: {
|
| 14 |
+
primary: '#2563eb',
|
| 15 |
+
secondary: '#f59e0b',
|
| 16 |
+
tertiary: '#10b981',
|
| 17 |
+
dark: '#1e293b',
|
| 18 |
+
light: '#f8fafc'
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
</script>
|
| 24 |
+
<style>
|
| 25 |
+
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Poppins:wght@300;400;500;600;700&display=swap');
|
| 26 |
+
|
| 27 |
+
body {
|
| 28 |
+
font-family: 'Poppins', sans-serif;
|
| 29 |
+
background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
|
| 30 |
+
color: #1e293b;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
h1, h2, h3 {
|
| 34 |
+
font-family: 'Poppins', sans-serif;
|
| 35 |
+
font-weight: 700;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.code-font {
|
| 39 |
+
font-family: 'JetBrains Mono', monospace;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.header-gradient {
|
| 43 |
+
background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.unit-card {
|
| 47 |
+
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
| 48 |
+
border-radius: 16px;
|
| 49 |
+
overflow: hidden;
|
| 50 |
+
border: none;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.unit-card:hover {
|
| 54 |
+
transform: translateY(-5px);
|
| 55 |
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.unit-1 { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }
|
| 59 |
+
.unit-2 { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
|
| 60 |
+
.unit-3 { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
|
| 61 |
+
|
| 62 |
+
.code-block {
|
| 63 |
+
background: #1e293b;
|
| 64 |
+
border-radius: 12px;
|
| 65 |
+
padding: 1.5rem;
|
| 66 |
+
position: relative;
|
| 67 |
+
overflow-x: auto;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.code-block::before {
|
| 71 |
+
content: '';
|
| 72 |
+
position: absolute;
|
| 73 |
+
top: 12px;
|
| 74 |
+
left: 12px;
|
| 75 |
+
width: 12px;
|
| 76 |
+
height: 12px;
|
| 77 |
+
background: #ef4444;
|
| 78 |
+
border-radius: 50%;
|
| 79 |
+
box-shadow: 20px 0 0 #f59e0b, 40px 0 0 #10b981;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
.tip-card {
|
| 83 |
+
border-left: 4px solid #f59e0b;
|
| 84 |
+
background: rgba(245, 158, 11, 0.1);
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
.tip-card i {
|
| 88 |
+
color: #f59e0b;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
.table-container {
|
| 92 |
+
overflow-x: auto;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.highlight {
|
| 96 |
+
background: linear-gradient(120deg, rgba(251, 191, 36, 0.3) 0%, rgba(251, 191, 36, 0) 100%);
|
| 97 |
+
padding: 0.2rem 0.4rem;
|
| 98 |
+
border-radius: 4px;
|
| 99 |
+
font-weight: 600;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.key-point {
|
| 103 |
+
background: rgba(37, 99, 235, 0.1);
|
| 104 |
+
border-radius: 8px;
|
| 105 |
+
padding: 1.5rem;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.concept-pill {
|
| 109 |
+
background: rgba(37, 99, 235, 0.1);
|
| 110 |
+
padding: 0.5rem 1rem;
|
| 111 |
+
border-radius: 9999px;
|
| 112 |
+
font-weight: 600;
|
| 113 |
+
display: inline-flex;
|
| 114 |
+
align-items: center;
|
| 115 |
+
gap: 0.5rem;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
.badge {
|
| 119 |
+
padding: 0.25rem 0.75rem;
|
| 120 |
+
border-radius: 9999px;
|
| 121 |
+
font-weight: 600;
|
| 122 |
+
font-size: 0.75rem;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
@media (max-width: 768px) {
|
| 126 |
+
.header-content {
|
| 127 |
+
flex-direction: column;
|
| 128 |
+
text-align: center;
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
</style>
|
| 132 |
+
</head>
|
| 133 |
+
<body class="min-h-screen py-8 px-4 sm:px-6 lg:px-8">
|
| 134 |
+
<div class="max-w-6xl mx-auto">
|
| 135 |
+
<!-- Header -->
|
| 136 |
+
<header class="header-gradient text-white rounded-2xl shadow-xl mb-12 overflow-hidden">
|
| 137 |
+
<div class="p-8 md:p-12">
|
| 138 |
+
<div class="flex flex-col md:flex-row items-center justify-between gap-6 header-content">
|
| 139 |
+
<div class="flex items-center gap-4">
|
| 140 |
+
<div class="bg-white/20 p-4 rounded-xl">
|
| 141 |
+
<i class="fas fa-file-code text-4xl"></i>
|
| 142 |
+
</div>
|
| 143 |
+
<div>
|
| 144 |
+
<h1 class="text-3xl md:text-4xl font-bold">C++ Exam Cheat Sheet (1-Page)</h1>
|
| 145 |
+
<div class="mt-2 flex flex-wrap gap-2">
|
| 146 |
+
<span class="badge bg-white/20">OOP</span>
|
| 147 |
+
<span class="badge bg-white/20">C++</span>
|
| 148 |
+
<span class="badge bg-white/20">Exam Prep</span>
|
| 149 |
+
</div>
|
| 150 |
+
</div>
|
| 151 |
+
</div>
|
| 152 |
+
<div class="text-center md:text-right">
|
| 153 |
+
<p class="text-lg font-medium"><i class="fas fa-book mr-2"></i>Subject: Object-Oriented Programming with C++</p>
|
| 154 |
+
<p class="text-lg mt-1"><i class="fas fa-user-graduate mr-2"></i>For: Diploma in Computer Engineering (2nd Year)</p>
|
| 155 |
+
<p class="text-lg mt-1"><i class="fas fa-database mr-2"></i>Based on: Official Question Bank (Units 1β3)</p>
|
| 156 |
+
</div>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
</header>
|
| 160 |
+
|
| 161 |
+
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
| 162 |
+
<!-- Unit 1 -->
|
| 163 |
+
<div class="unit-card bg-white shadow-lg">
|
| 164 |
+
<div class="unit-1 text-white p-6">
|
| 165 |
+
<h2 class="text-2xl font-bold flex items-center gap-2">
|
| 166 |
+
<i class="fas fa-cube"></i> UNIT 1: Principles of OOP
|
| 167 |
+
</h2>
|
| 168 |
+
</div>
|
| 169 |
+
<div class="p-6">
|
| 170 |
+
<!-- OOP Definition -->
|
| 171 |
+
<div class="mb-8">
|
| 172 |
+
<div class="flex items-center gap-2 mb-4">
|
| 173 |
+
<h3 class="text-xl font-bold text-primary">OOP Definition (2 marks)</h3>
|
| 174 |
+
<span class="badge bg-primary/20 text-primary">Key Concept</span>
|
| 175 |
+
</div>
|
| 176 |
+
<div class="bg-blue-50 p-4 rounded-lg border-l-4 border-primary mb-4">
|
| 177 |
+
<p class="font-medium">
|
| 178 |
+
<span class="highlight">OOP</span> = Object-Oriented Programming. It uses
|
| 179 |
+
<span class="highlight">objects</span> (instances of classes) to model real-world entities.
|
| 180 |
+
Focuses on <span class="highlight">data security, reusability, and modularity</span>.
|
| 181 |
+
</p>
|
| 182 |
+
</div>
|
| 183 |
+
<div class="mt-4">
|
| 184 |
+
<h4 class="font-bold text-lg text-dark mb-2">Core Concepts (Remember A PIE):</h4>
|
| 185 |
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
| 186 |
+
<div class="concept-pill text-primary">
|
| 187 |
+
<i class="fas fa-eye-slash"></i> <span class="font-bold">A</span>bstracton β Hide internal details
|
| 188 |
+
</div>
|
| 189 |
+
<div class="concept-pill text-primary">
|
| 190 |
+
<i class="fas fa-shapes"></i> <span class="font-bold">P</span>olymorphism β One name, many forms
|
| 191 |
+
</div>
|
| 192 |
+
<div class="concept-pill text-primary">
|
| 193 |
+
<i class="fas fa-sitemap"></i> <span class="font-bold">I</span>nheritance β Reuse parent class
|
| 194 |
+
</div>
|
| 195 |
+
<div class="concept-pill text-primary">
|
| 196 |
+
<i class="fas fa-box"></i> <span class="font-bold">E</span>ncapsulation β Bind data + functions
|
| 197 |
+
</div>
|
| 198 |
+
</div>
|
| 199 |
+
</div>
|
| 200 |
+
</div>
|
| 201 |
+
|
| 202 |
+
<!-- OOP vs POP -->
|
| 203 |
+
<div class="mb-8">
|
| 204 |
+
<h3 class="text-xl font-bold text-primary mb-4">OOP vs POP (3 marks)</h3>
|
| 205 |
+
<div class="table-container">
|
| 206 |
+
<table class="min-w-full divide-y divide-gray-200 border border-gray-200 rounded-lg overflow-hidden">
|
| 207 |
+
<thead class="bg-primary/10">
|
| 208 |
+
<tr>
|
| 209 |
+
<th class="px-4 py-3 text-left font-medium text-dark">Feature</th>
|
| 210 |
+
<th class="px-4 py-3 text-left font-medium text-dark">OOP</th>
|
| 211 |
+
<th class="px-4 py-3 text-left font-medium text-dark">POP</th>
|
| 212 |
+
</tr>
|
| 213 |
+
</thead>
|
| 214 |
+
<tbody class="divide-y divide-gray-200">
|
| 215 |
+
<tr class="hover:bg-gray-50">
|
| 216 |
+
<td class="px-4 py-3 font-medium">Approach</td>
|
| 217 |
+
<td class="px-4 py-3">Bottom-up</td>
|
| 218 |
+
<td class="px-4 py-3">Top-down</td>
|
| 219 |
+
</tr>
|
| 220 |
+
<tr class="hover:bg-gray-50">
|
| 221 |
+
<td class="px-4 py-3 font-medium">Data & Functions</td>
|
| 222 |
+
<td class="px-4 py-3">Combined (in objects)</td>
|
| 223 |
+
<td class="px-4 py-3">Separate</td>
|
| 224 |
+
</tr>
|
| 225 |
+
<tr class="hover:bg-gray-50">
|
| 226 |
+
<td class="px-4 py-3 font-medium">Inheritance</td>
|
| 227 |
+
<td class="px-4 py-3 text-green-600"><i class="fas fa-check-circle mr-1"></i> Yes</td>
|
| 228 |
+
<td class="px-4 py-3 text-red-600"><i class="fas fa-times-circle mr-1"></i> No</td>
|
| 229 |
+
</tr>
|
| 230 |
+
<tr class="hover:bg-gray-50">
|
| 231 |
+
<td class="px-4 py-3 font-medium">Access Control</td>
|
| 232 |
+
<td class="px-4 py-3 text-green-600"><i class="fas fa-check-circle mr-1"></i> (public/private)</td>
|
| 233 |
+
<td class="px-4 py-3 text-red-600"><i class="fas fa-times-circle mr-1"></i> No</td>
|
| 234 |
+
</tr>
|
| 235 |
+
<tr class="hover:bg-gray-50">
|
| 236 |
+
<td class="px-4 py-3 font-medium">Examples</td>
|
| 237 |
+
<td class="px-4 py-3">C++, Java</td>
|
| 238 |
+
<td class="px-4 py-3">C, BASIC</td>
|
| 239 |
+
</tr>
|
| 240 |
+
</tbody>
|
| 241 |
+
</table>
|
| 242 |
+
</div>
|
| 243 |
+
</div>
|
| 244 |
+
|
| 245 |
+
<!-- Access Specifiers -->
|
| 246 |
+
<div class="mb-8">
|
| 247 |
+
<h3 class="text-xl font-bold text-primary mb-4">Access Specifiers (3β4 marks)</h3>
|
| 248 |
+
<div class="table-container">
|
| 249 |
+
<table class="min-w-full divide-y divide-gray-200 border border-gray-200 rounded-lg overflow-hidden">
|
| 250 |
+
<thead class="bg-primary/10">
|
| 251 |
+
<tr>
|
| 252 |
+
<th class="px-4 py-3 text-left font-medium text-dark">Specifier</th>
|
| 253 |
+
<th class="px-4 py-3 text-left font-medium text-dark">Access</th>
|
| 254 |
+
</tr>
|
| 255 |
+
</thead>
|
| 256 |
+
<tbody class="divide-y divide-gray-200">
|
| 257 |
+
<tr class="hover:bg-gray-50">
|
| 258 |
+
<td class="px-4 py-3 font-medium"><code>public</code></td>
|
| 259 |
+
<td class="px-4 py-3">Anywhere</td>
|
| 260 |
+
</tr>
|
| 261 |
+
<tr class="hover:bg-gray-50">
|
| 262 |
+
<td class="px-4 py-3 font-medium"><code>private</code></td>
|
| 263 |
+
<td class="px-4 py-3">Only in class</td>
|
| 264 |
+
</tr>
|
| 265 |
+
<tr class="hover:bg-gray-50">
|
| 266 |
+
<td class="px-4 py-3 font-medium"><code>protected</code></td>
|
| 267 |
+
<td class="px-4 py-3">In class & derived classes</td>
|
| 268 |
+
</tr>
|
| 269 |
+
</tbody>
|
| 270 |
+
</table>
|
| 271 |
+
</div>
|
| 272 |
+
<div class="mt-4 bg-yellow-50 p-4 rounded-lg border-l-4 border-yellow-500">
|
| 273 |
+
<p class="font-medium text-dark">
|
| 274 |
+
<i class="fas fa-exclamation-circle text-yellow-500 mr-2"></i>
|
| 275 |
+
<code>private</code> members <span class="font-bold">cannot be accessed in <code>main()</code></span>.
|
| 276 |
+
</p>
|
| 277 |
+
</div>
|
| 278 |
+
</div>
|
| 279 |
+
|
| 280 |
+
<!-- Scope Resolution Operator -->
|
| 281 |
+
<div>
|
| 282 |
+
<h3 class="text-xl font-bold text-primary mb-4">Scope Resolution Operator (::) (3 marks)</h3>
|
| 283 |
+
<p class="mb-4">Used to:</p>
|
| 284 |
+
<ol class="list-decimal list-inside mb-4 space-y-2">
|
| 285 |
+
<li>Access <span class="highlight">global variable</span> when local has same name</li>
|
| 286 |
+
<li>Define <span class="highlight">member functions outside class</span></li>
|
| 287 |
+
</ol>
|
| 288 |
+
<div class="code-block">
|
| 289 |
+
<pre class="text-green-400 code-font"><code>int x = 10;
|
| 290 |
+
int main() {
|
| 291 |
+
int x = 20;
|
| 292 |
+
cout << ::x; // prints 10
|
| 293 |
+
}</code></pre>
|
| 294 |
+
</div>
|
| 295 |
+
</div>
|
| 296 |
+
</div>
|
| 297 |
+
</div>
|
| 298 |
+
|
| 299 |
+
<!-- Unit 2 -->
|
| 300 |
+
<div class="unit-card bg-white shadow-lg">
|
| 301 |
+
<div class="unit-2 text-white p-6">
|
| 302 |
+
<h2 class="text-2xl font-bold flex items-center gap-2">
|
| 303 |
+
<i class="fas fa-functions"></i> UNIT 2: Functions, Classes & Objects
|
| 304 |
+
</h2>
|
| 305 |
+
</div>
|
| 306 |
+
<div class="p-6">
|
| 307 |
+
<!-- Inline Function -->
|
| 308 |
+
<div class="mb-8">
|
| 309 |
+
<h3 class="text-xl font-bold text-secondary mb-4">Inline Function (3β4 marks)</h3>
|
| 310 |
+
<div class="bg-amber-50 p-4 rounded-lg border-l-4 border-secondary mb-4">
|
| 311 |
+
<p class="font-medium">
|
| 312 |
+
Function expanded at compile time for speed. Use <code class="highlight">inline</code> keyword.
|
| 313 |
+
</p>
|
| 314 |
+
</div>
|
| 315 |
+
<div class="code-block">
|
| 316 |
+
<pre class="text-green-400 code-font"><code>inline int cube(int a) {
|
| 317 |
+
return a * a * a;
|
| 318 |
+
}</code></pre>
|
| 319 |
+
</div>
|
| 320 |
+
<div class="mt-4 bg-yellow-50 p-4 rounded-lg border-l-4 border-yellow-500">
|
| 321 |
+
<p class="font-medium text-dark">
|
| 322 |
+
<i class="fas fa-lightbulb text-yellow-500 mr-2"></i>
|
| 323 |
+
Use for <span class="font-bold">short, frequently called functions</span>.
|
| 324 |
+
</p>
|
| 325 |
+
</div>
|
| 326 |
+
</div>
|
| 327 |
+
|
| 328 |
+
<!-- Function Overloading -->
|
| 329 |
+
<div class="mb-8">
|
| 330 |
+
<h3 class="text-xl font-bold text-secondary mb-4">Function Overloading (3β4 marks)</h3>
|
| 331 |
+
<div class="bg-amber-50 p-4 rounded-lg border-l-4 border-secondary mb-4">
|
| 332 |
+
<p class="font-medium">
|
| 333 |
+
Same name, <span class="highlight">different parameters</span> (number or type).
|
| 334 |
+
<span class="font-bold">Not by return type</span>.
|
| 335 |
+
</p>
|
| 336 |
+
</div>
|
| 337 |
+
<div class="code-block">
|
| 338 |
+
<pre class="text-green-400 code-font"><code>class Cal {
|
| 339 |
+
public:
|
| 340 |
+
int add(int a, int b) { return a+b; }
|
| 341 |
+
int add(int a, int b, int c) { return a+b+c; }
|
| 342 |
+
};</code></pre>
|
| 343 |
+
</div>
|
| 344 |
+
</div>
|
| 345 |
+
|
| 346 |
+
<!-- Friend Function -->
|
| 347 |
+
<div class="mb-8">
|
| 348 |
+
<h3 class="text-xl font-bold text-secondary mb-4">Friend Function (3 marks)</h3>
|
| 349 |
+
<div class="bg-amber-50 p-4 rounded-lg border-l-4 border-secondary mb-4">
|
| 350 |
+
<p class="font-medium">
|
| 351 |
+
Non-member function that can access <code>private</code> members using <code>friend</code>.
|
| 352 |
+
</p>
|
| 353 |
+
</div>
|
| 354 |
+
<div class="code-block">
|
| 355 |
+
<pre class="text-green-400 code-font"><code>class Test {
|
| 356 |
+
int a;
|
| 357 |
+
public:
|
| 358 |
+
friend void show(Test t);
|
| 359 |
+
};
|
| 360 |
+
|
| 361 |
+
void show(Test t) {
|
| 362 |
+
cout << t.a; // OK!
|
| 363 |
+
}</code></pre>
|
| 364 |
+
</div>
|
| 365 |
+
</div>
|
| 366 |
+
|
| 367 |
+
<!-- Class & Object -->
|
| 368 |
+
<div>
|
| 369 |
+
<h3 class="text-xl font-bold text-secondary mb-4">Class & Object (2 marks)</h3>
|
| 370 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 371 |
+
<div class="key-point">
|
| 372 |
+
<h4 class="font-bold text-lg text-secondary mb-2 flex items-center gap-2">
|
| 373 |
+
<i class="fas fa-blueprint"></i> Class
|
| 374 |
+
</h4>
|
| 375 |
+
<p>Blueprint (<code class="bg-secondary/10 p-1 rounded">class Student {};</code>)</p>
|
| 376 |
+
</div>
|
| 377 |
+
<div class="key-point">
|
| 378 |
+
<h4 class="font-bold text-lg text-secondary mb-2 flex items-center gap-2">
|
| 379 |
+
<i class="fas fa-cube"></i> Object
|
| 380 |
+
</h4>
|
| 381 |
+
<p>Instance (<code class="bg-secondary/10 p-1 rounded">Student s1;</code>)</p>
|
| 382 |
+
</div>
|
| 383 |
+
</div>
|
| 384 |
+
<div class="mt-4 bg-yellow-50 p-4 rounded-lg border-l-4 border-yellow-500">
|
| 385 |
+
<p class="font-medium text-dark">
|
| 386 |
+
<i class="fas fa-info-circle text-yellow-500 mr-2"></i>
|
| 387 |
+
An <span class="font-bold">instance of a class</span> = object created at runtime.
|
| 388 |
+
</p>
|
| 389 |
+
</div>
|
| 390 |
+
</div>
|
| 391 |
+
</div>
|
| 392 |
+
</div>
|
| 393 |
+
|
| 394 |
+
<!-- Unit 3 -->
|
| 395 |
+
<div class="unit-card bg-white shadow-lg">
|
| 396 |
+
<div class="unit-3 text-white p-6">
|
| 397 |
+
<h2 class="text-2xl font-bold flex items-center gap-2">
|
| 398 |
+
<i class="fas fa-tools"></i> UNIT 3: Constructor & Destructor
|
| 399 |
+
</h2>
|
| 400 |
+
</div>
|
| 401 |
+
<div class="p-6">
|
| 402 |
+
<!-- Constructor -->
|
| 403 |
+
<div class="mb-8">
|
| 404 |
+
<h3 class="text-xl font-bold text-tertiary mb-4">Constructor (3 marks)</h3>
|
| 405 |
+
<div class="bg-emerald-50 p-4 rounded-lg border-l-4 border-tertiary mb-4">
|
| 406 |
+
<p class="font-medium">
|
| 407 |
+
Special function with <span class="highlight">same name as class</span>, called
|
| 408 |
+
<span class="highlight">automatically</span> when object is created.
|
| 409 |
+
<span class="font-bold">No return type</span>.
|
| 410 |
+
</p>
|
| 411 |
+
</div>
|
| 412 |
+
<div>
|
| 413 |
+
<h4 class="font-bold text-lg text-dark mb-3">Types:</h4>
|
| 414 |
+
<div class="space-y-3">
|
| 415 |
+
<div class="flex items-start gap-3">
|
| 416 |
+
<div class="bg-tertiary text-white rounded-full h-6 w-6 flex items-center justify-center mt-1 flex-shrink-0">1</div>
|
| 417 |
+
<div>
|
| 418 |
+
<span class="font-bold">Default</span> β No parameters
|
| 419 |
+
</div>
|
| 420 |
+
</div>
|
| 421 |
+
<div class="flex items-start gap-3">
|
| 422 |
+
<div class="bg-tertiary text-white rounded-full h-6 w-6 flex items-center justify-center mt-1 flex-shrink-0">2</div>
|
| 423 |
+
<div>
|
| 424 |
+
<span class="font-bold">Parameterized</span> β Takes parameters
|
| 425 |
+
</div>
|
| 426 |
+
</div>
|
| 427 |
+
<div class="flex items-start gap-3">
|
| 428 |
+
<div class="bg-tertiary text-white rounded-full h-6 w-6 flex items-center justify-center mt-1 flex-shrink-0">3</div>
|
| 429 |
+
<div>
|
| 430 |
+
<span class="font-bold">Copy</span> β Initializes using another object
|
| 431 |
+
</div>
|
| 432 |
+
</div>
|
| 433 |
+
</div>
|
| 434 |
+
</div>
|
| 435 |
+
</div>
|
| 436 |
+
|
| 437 |
+
<!-- Parameterized Constructor -->
|
| 438 |
+
<div class="mb-8">
|
| 439 |
+
<h3 class="text-xl font-bold text-tertiary mb-4">Parameterized Constructor (3β4 marks)</h3>
|
| 440 |
+
<div class="code-block">
|
| 441 |
+
<pre class="text-green-400 code-font"><code>class Student {
|
| 442 |
+
public:
|
| 443 |
+
int id;
|
| 444 |
+
string name;
|
| 445 |
+
Student(int i, string n) {
|
| 446 |
+
id = i;
|
| 447 |
+
name = n;
|
| 448 |
+
}
|
| 449 |
+
};
|
| 450 |
+
|
| 451 |
+
// Usage: Student s(101, "Rahul");</code></pre>
|
| 452 |
+
</div>
|
| 453 |
+
</div>
|
| 454 |
+
|
| 455 |
+
<!-- Program: Student Details -->
|
| 456 |
+
<div>
|
| 457 |
+
<h3 class="text-xl font-bold text-tertiary mb-4">Program: Student Details (3 marks)</h3>
|
| 458 |
+
<div class="code-block">
|
| 459 |
+
<pre class="text-green-400 code-font"><code>#include <iostream>
|
| 460 |
+
using namespace std;
|
| 461 |
+
|
| 462 |
+
class Student {
|
| 463 |
+
public:
|
| 464 |
+
int id;
|
| 465 |
+
string name;
|
| 466 |
+
float salary;
|
| 467 |
+
Student(int i, string n, float s) {
|
| 468 |
+
id = i;
|
| 469 |
+
name = n;
|
| 470 |
+
salary = s;
|
| 471 |
+
}
|
| 472 |
+
void display() {
|
| 473 |
+
cout << id << " " << name << " " << salary << endl;
|
| 474 |
+
}
|
| 475 |
+
};
|
| 476 |
+
|
| 477 |
+
int main() {
|
| 478 |
+
Student s1(101, "Rahul", 50000);
|
| 479 |
+
s1.display();
|
| 480 |
+
return 0;
|
| 481 |
+
}</code></pre>
|
| 482 |
+
</div>
|
| 483 |
+
<div class="mt-4 bg-emerald-50 p-4 rounded-lg border-l-4 border-emerald-500">
|
| 484 |
+
<p class="font-medium text-dark">
|
| 485 |
+
<i class="fas fa-pen-alt text-emerald-500 mr-2"></i>
|
| 486 |
+
<span class="font-bold">Write this in exam</span> β covers Q25, Q27, and constructor use.
|
| 487 |
+
</p>
|
| 488 |
+
</div>
|
| 489 |
+
</div>
|
| 490 |
+
</div>
|
| 491 |
+
</div>
|
| 492 |
+
</div>
|
| 493 |
+
|
| 494 |
+
<!-- Quick Tips Section -->
|
| 495 |
+
<div class="mt-12 bg-white rounded-2xl shadow-lg overflow-hidden">
|
| 496 |
+
<div class="bg-gradient-to-r from-primary to-secondary p-6">
|
| 497 |
+
<h2 class="text-2xl font-bold text-white flex items-center gap-3">
|
| 498 |
+
<i class="fas fa-lightbulb"></i> Quick Tips for Exam
|
| 499 |
+
</h2>
|
| 500 |
+
</div>
|
| 501 |
+
<div class="p-6 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
| 502 |
+
<div class="tip-card p-5 rounded-lg flex items-start gap-3">
|
| 503 |
+
<i class="fas fa-pen text-2xl mt-1"></i>
|
| 504 |
+
<div>
|
| 505 |
+
<h3 class="font-bold text-lg text-dark mb-2">Write Neatly & Underline</h3>
|
| 506 |
+
<p>Underline keywords: <code class="bg-primary/10 p-1 rounded">private</code>,
|
| 507 |
+
<code class="bg-primary/10 p-1 rounded">friend</code>,
|
| 508 |
+
<code class="bg-primary/10 p-1 rounded">inline</code>,
|
| 509 |
+
<code class="bg-primary/10 p-1 rounded">::</code></p>
|
| 510 |
+
</div>
|
| 511 |
+
</div>
|
| 512 |
+
|
| 513 |
+
<div class="tip-card p-5 rounded-lg flex items-start gap-3">
|
| 514 |
+
<i class="fas fa-table text-2xl mt-1"></i>
|
| 515 |
+
<div>
|
| 516 |
+
<h3 class="font-bold text-lg text-dark mb-2">Draw Tables</h3>
|
| 517 |
+
<p>For comparisons (OOP vs POP, access specifiers) to organize information clearly.</p>
|
| 518 |
+
</div>
|
| 519 |
+
</div>
|
| 520 |
+
|
| 521 |
+
<div class="tip-card p-5 rounded-lg flex items-start gap-3">
|
| 522 |
+
<i class="fas fa-code text-2xl mt-1"></i>
|
| 523 |
+
<div>
|
| 524 |
+
<h3 class="font-bold text-lg text-dark mb-2">Write Small Code</h3>
|
| 525 |
+
<p>Even 4 lines with comments = full marks. Focus on key concepts.</p>
|
| 526 |
+
</div>
|
| 527 |
+
</div>
|
| 528 |
+
|
| 529 |
+
<div class="tip-card p-5 rounded-lg flex items-start gap-3">
|
| 530 |
+
<i class="fas fa-hourglass-half text-2xl mt-1"></i>
|
| 531 |
+
<div>
|
| 532 |
+
<h3 class="font-bold text-lg text-dark mb-2">Time Management</h3>
|
| 533 |
+
<p>Spend 1 min per 2 marks β don't over-write answers.</p>
|
| 534 |
+
</div>
|
| 535 |
+
</div>
|
| 536 |
+
|
| 537 |
+
<div class="tip-card p-5 rounded-lg flex items-start gap-3">
|
| 538 |
+
<i class="fas fa-exclamation-triangle text-2xl mt-1"></i>
|
| 539 |
+
<div>
|
| 540 |
+
<h3 class="font-bold text-lg text-dark mb-2">Don't Leave Blanks</h3>
|
| 541 |
+
<p>If blank, write something β definition, syntax, or example.</p>
|
| 542 |
+
</div>
|
| 543 |
+
</div>
|
| 544 |
+
|
| 545 |
+
<div class="tip-card p-5 rounded-lg flex items-start gap-3">
|
| 546 |
+
<i class="fas fa-check-circle text-2xl mt-1"></i>
|
| 547 |
+
<div>
|
| 548 |
+
<h3 class="font-bold text-lg text-dark mb-2">Review Core Concepts</h3>
|
| 549 |
+
<p>Focus on A PIE (Abstraction, Polymorphism, Inheritance, Encapsulation).</p>
|
| 550 |
+
</div>
|
| 551 |
+
</div>
|
| 552 |
+
</div>
|
| 553 |
+
</div>
|
| 554 |
+
|
| 555 |
+
<!-- Footer -->
|
| 556 |
+
<footer class="mt-12 text-center text-gray-600">
|
| 557 |
+
<p class="mb-2">C++ Exam Cheat Sheet - Diploma in Computer Engineering (2nd Year)</p>
|
| 558 |
+
<p>Based on Official Question Bank - Units 1β3</p>
|
| 559 |
+
<div class="mt-4 flex justify-center gap-4">
|
| 560 |
+
<a href="#" class="text-primary hover:text-primary/80"><i class="fab fa-github"></i></a>
|
| 561 |
+
<a href="#" class="text-primary hover:text-primary/80"><i class="fab fa-linkedin"></i></a>
|
| 562 |
+
<a href="#" class="text-primary hover:text-primary/80"><i class="fas fa-envelope"></i></a>
|
| 563 |
+
</div>
|
| 564 |
+
</footer>
|
| 565 |
+
</div>
|
| 566 |
+
</body>
|
| 567 |
+
</html>
|