Relative Content

Tag Archive for c++c++11

Two almost similar multithreaded code have very different running time

i am having a strange problem for C++ multithreaded programs.
i wrote the first code and was not seeing any performance improvement over single threaded code.
i kept on experimenting with shifting the variables in the functions and the second code took almost half the time of first code.

How should I correctly understand the concept of effective types in the C11 standard?

Frankly speaking, the concepts of effective types and strict aliasing in the C11 standard are quite a headache for me to read.Now, I have some of my own understanding of the concept of effective types, and at the same time, I also have some doubts.
The C11 standard introduces effective types as follows. I will extract some key sentences from it and divide them into multiple paragraphs to facilitate raising my questions later:(Perhaps my question is very long. I would be very grateful if you could finish reading it.)
6.5 p6:

Strugling a bit with c++ (no programming background)

I need some help. I’m struggling with learning C++ i’m learning from the book “C++ Primer 5th edition (i’m french native).” I have no programming background and I’m currently at the section on vectors. I understand the basics of C++ (data types, loops, if-else statements, switch, etc.), but when I try to solve a problem, I can’t break it down correctly most of the time even smallest problem. I feel overwhelmed and my mind goes blank.

Bank Management Beginner Project

#include <iostream> #include <string> #include <vector> #include <cctype> using std::cout; using std::cin; using std::string; using std::vector; class Account { private: string name, password; double balance; int account; public: Account(string accountName, string password, double initialBalance, int accountNumber) : name(accountName), password(password), balance(initialBalance), account(accountNumber) {} void deposit(double amount) { if (amount > 0) { balance += amount; cout […]

Bank Management Beginner Peoject

#include <iostream> #include <string> #include <vector> #include <cctype> using std::cout; using std::cin; using std::string; using std::vector; class Account { private: string name, password; double balance; int account; public: Account(string accountName, string password, double initialBalance, int accountNumber) : name(accountName), password(password), balance(initialBalance), account(accountNumber) {} void deposit(double amount) { if (amount > 0) { balance += amount; cout […]