File size: 28,048 Bytes
c6ee7d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
<!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 << ::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 << 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 <iostream>
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 << id << " " << name << " " << salary << 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> |