Jul 29, 2024
int* ptr = &var; // ptr stores the address of var
std::cout << *ptr;
std::cout << ptr;
int
- 4 bytesfloat
- 4 bytesdouble
- 8 byteschar
- 1 byteint arr[5] = {1, 2, 3, 4, 5}; int* ptr = arr;
void func(int& a)
vs. void func(int a)
struct Car {
int wheels;
std::string brand;
std::string color;
int maxSpeed;
void printProperties();
};
Car myCar;
myCar.wheels = 4;
private
for private members (not accessible outside class)public
for public membersMyClass() { /*...*/ }
~MyClass() { /*...*/ }
class Car : public Vehicle {
std::string model;
// Additional members and methods
};
private
for sensitive data.void func();
void func(int a);
void func(int a, float b);
virtual
keyword.class Vehicle {
virtual void getClassType() { std::cout << "Vehicle"; }
};
class Car : public Vehicle {
void getClassType() override { std::cout << "Car"; }
};
virtual void myMethod();