1.
C++ Core Concepts with Examples
A. Object-Oriented Programming (OOP)
- Class and Object:
```cpp
class Car {
public:
string brand;
void drive() { cout << "Driving " << brand; }
};
```
- Inheritance:
```cpp
class Vehicle { public: void start() { cout << "Started"; } };
class Car : public Vehicle { };
```
- Polymorphism:
```cpp
class Base { public: virtual void show() { cout << "Base"; } };
class Derived : public Base { public: void show() override { cout << "Derived"; } };
```
- Smart Pointers (C++11):
```cpp
#include
unique_ptr p(new int(10));
```
B. STL (Standard Template Library)
- Vectors, Maps, Sets:
```cpp
vector v = {1, 2, 3};
map phonebook = {{"Alice", 123}};
```
C. Multithreading:
```cpp
#include
void run() { cout << "Thread running"; }
int main() { thread t(run); t.join(); }
```
D. Memory Management:
- Use `new` and `delete`, but prefer smart pointers.
E. Exception Handling:
```cpp
try { throw 20; } catch (int e) { cout << "Error: " << e; }
```
2. Linux & Shell Scripting Basics
A. Essential Linux Commands:
- `ls`, `cd`, `pwd`, `cp`, `mv`, `rm`, `grep`, `find`, `top`, `kill`, `chmod`,
`chown`, `tar`, `ssh`
B. Bash Script Example:
```bash
#!/bin/bash
for i in {1..5}; do
echo "Welcome $i times"
done
```
C. Monitoring Disk Usage:
```bash
df -h
du -sh /home/user/*
```
D. File Permissions:
- `chmod 755 script.sh`, `chown user:user file.txt`
3. Python Scripting Basics
A. Syntax:
```python
def greet(name):
print(f"Hello, {name}")
greet("Alice")
```
B. File Handling:
```python
with open("file.txt", "r") as f:
print(f.read())
```
C. Automation Example:
```python
import os
for file in os.listdir("."):
if file.endswith(".log"):
print(file)
```
D. JSON & API Parsing:
```python
import json
data = '{"name":"Alice"}'
parsed = json.loads(data)
print(parsed["name"])
```
4. Git & CI/CD Tools
A. Git Commands:
- `git init`, `git clone`, `git add`, `git commit -m`, `git push`, `git pull`, `git
branch`, `git merge`
B. Git Workflow:
- Feature Branch → Commit → Pull Request → Merge
C. CI/CD Concepts:
- Continuous Integration: frequent integration of code into shared repo.
- Continuous Deployment: automatic deployment after successful tests.
D. Jenkins Pipeline (basic):
```groovy
pipeline {
agent any
stages {
stage('Build') { steps { sh 'make' } }
stage('Test') { steps { sh './run_tests.sh' } }
}
}
```