This group is created to discuss issues related to C++ programming

9 Members
Join Us!

You need to be a member of Virtual Academy of Pakistan to add comments!

Join Virtual Academy of Pakistan

Comments are closed.

Python Decorators: Custom Logging for Function Calls

 I'm working on a Python project where I have multiple functions, and I want to log each function call along with its arguments and return value for debugging purposes. I've heard that decorators can help achieve this. Could someone guide me on how to create a custom decorator for logging function calls?Here's what I have in mind: [code]def log_function_call(func): def wrapper(*args, **kwargs): # Log function call, arguments, and return value result = func(*args, **kwargs) # Log the result…

Read more…
0 Replies

conditional operator

Hello, I just have a quick question about the conditional operator. Still a budding programmer here, I was going through this - https://www.scaler.com/topics/c/conditional-operator-in-c/  on conditional operator in c and wanted to understand as I am given x = 1, y = 2, and z = 3.I want to know, why after this statement: {Codey += x-- ? z++ : --z;That y is 5. The values after the statement are x = 0, y = 5, and z = 4. I know the way the conditional operator works is that it is formatted like…

Read more…
0 Replies

How to use for each loop in c++

 {Code}#include <cstdlib> #include <iostream> #include <string>using namespace std;int main() { string str("hello world!"); for (auto &c : str) c = toupper(c); cout << str; return 0; }This c++ code does not compile. Error msg: main.cpp:21: error: a function-definition is not allowed here before ':' token Question: Is there a for each loop in c++ (range for loop?)? what is wrong with the for each loop above? 

Read more…
1 Reply · Reply by SK-MSSE Jul 14, 2022