Vlad
So it becomes 1
Anonymous
cause 0 || 1 is true
but Isn't && AND evaluated before OR ?
class Person(Skills): name = str("Ankush Bhagat")
Anonymous
yeah I got it
Anonymous
it's because of ()
Vlad
You've put brackets so || must be executed first
Pavel
Is there an STL analogue of golang channels? In other words I'm thinking about some way of passing data like: Channel<SomeData> channel; std::thread myThread([channel&]{ SomeData val = channel.read(); }); SomeData data; ... channel.write(std::move(data)); If write() is hit first the main thread is suspended until the spawned thread hit read(). If read() hit first then the spawned thread is suspended until the main thread hit write(). When both threads are on read() and write() the data is moved to the spawned thread and both threads continue execution.
Steven
what about std::promise/std::future pair
Aleksandr
Hello! I am trying to write an emulation of mouse cursor control through a gamepad on linux I use XWarpPointer for this, everything seems to be fine, but there was a problem. In games, when I turn the camera, I run into a "wall" at the edges Display *display = XGetMainDisplay(); XWarpPointer(display, None, None, 0,0,0,0, point.x, point.y); XSync(display, false);
Anonymous
Hello. I'm trying to use a pointer inside the base class and point it to derivative class object so call print() with using that pointer, I wrote this: #include <iostream> using namespace std; class base { public: virtual void print() { cout << "base\n"; } void SetPoint(something* _mypointer) { mypointer = _mypointer; } something* mypointer; }; class something : public base { public: void print() { cout << "something\n"; } private: string nuclear; }; int main() { std::cout << "Hello World!\n"; base MyLittleBase; something WhatIsThis; MyLittleBase.print(); WhatIsThis.print(); MyLittleBase.mypointer = &WhatIsThis; MyLittleBase.mypointer->print(); } and compiler give me this:
Anonymous
Severity Code Description Project File Line Suppression State Error C2061 syntax error: identifier 'something' tempcpp \tempcpp.cpp 11 Error C2143 syntax error: missing ';' before '*' tempcpp p\tempcpp.cpp 15 Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int tempcpp \tempcpp.cpp 15 Error C2238 unexpected token(s) preceding ';' tempcpp \tempcpp.cpp 15 Error C2065 'mypointer': undeclared identifier tempcpp \tempcpp.cpp 13 Error C2065 '_mypointer': undeclared identifier tempcpp \tempcpp.cpp 13 Error C2039 'mypointer': is not a member of 'base' tempcpp \tempcpp.cpp 35 Error C2039 'mypointer': is not a member of 'base' tempcpp \tempcpp.cpp 36
Anonymous
Anyone knows what should I do to fix this? and don't put pointer out of the base class, Tnx
Anonymous
Anyone knows what should I do to fix this? and don't put pointer out of the base class, Tnx
Forward declare something class by adding this line before base class definition: class something; PS - You need to change your naming convention style. It is the opposite of what most people expect.
Anonymous
Forward declare something class by adding this line before base class definition: class something; PS - You need to change your naming convention style. It is the opposite of what most people expect.
If I do this compiler won't define base for creating derivative class: I know. I don't use this naming usually but this time I want it to be funny -_-
Anonymous
If I do this compiler won't define base for creating derivative class: I know. I don't use this naming usually but this time I want it to be funny -_-
I said forward declare and not define. Just add that line alone and leave the rest of your code as it is. In base class you are using a pointer to something. The compiler wont know what something is unless you declare it. It can be an incomplete type. So just add the line class something; before the place where you define base class and it would fix your issue.
Bharti
How to convert euros to cents
Bharti
Using c++ constructor
Prince
If i don't include goto in my program while programming a game for instance,is there any effect because I don't understand the use of this goto
Anonymous
does anyone know here how to add cancel seat reservation on my program? i am using c
Official hooligan of Pius XII
Anonymous
does anyone know here how to add cancel seat reservation on my program? i am using c
#include<stdlib.h> #include <stdio.h> #include <stdbool.h> struct block { char theblock[5][4]; }; struct block blockArray[1]; int main(){ char answer; bool valid = true; char blocked_seats[2]; int reserved_seats = 0; struct block temp = { { {'A', 'B', 'C', 'D'}, {'A', 'B', 'C', 'D'}, {'A', 'B', 'C', 'D'}, {'A', 'B', 'C', 'D'},{'A', 'B', 'C', 'D'}} } ; blockArray[0] = temp ; printf("Available seats\n"); for (int i = 0; i < 5; i++){ printf("%d \t",i+1); for (int j = 0; j < 4; j++){ printf("%c \t",blockArray[0].theblock[i][j]); } printf("\n"); } while(valid == true){ int columnValue; printf("\nPlease enter seat code to reserve (1B,2A format)\n"); scanf( "%s", blocked_seats ); switch(blocked_seats[1]){ case 'A' : columnValue = 0; break; case 'B' : columnValue = 1; break; case 'C' : columnValue = 2; break; case 'D' : columnValue = 3; break; default : break; } int columnToBeBlocked = columnValue; printf("%d",columnToBeBlocked); char c = blocked_seats[0]; int rowToBeBlocked = c - '0'; printf("%d",rowToBeBlocked); if(blockArray[0].theblock[rowToBeBlocked-1][columnToBeBlocked] != 'X' && reserved_seats != 20){ blockArray[0].theblock[rowToBeBlocked-1][columnToBeBlocked] = 'X'; reserved_seats++; printf("seat successfully reserved\n"); for (int i = 0; i < 5; i++){ printf("%d \t",i+1); for (int j = 0; j < 4; j++){ printf("%c \t",blockArray[0].theblock[i][j]); } printf("\n"); } } else {printf("seat already taken!\n"); } if(reserved_seats == 20 ) valid = false; printf("\nDo you want to assign more seat? Y or N: \n"); scanf(" %c", &answer); if(answer == 'N') valid = false; } return 0; }
Anonymous
https://dpaste.org/AWDv its almost a calender i want help in 2 things firstlty to allign the numbers under week days --------------------january---------------- sun mon tue wed thu fri sat 1234567 891011121314 15161718192021 22232425262728 293031 --------------------feb---------------- sun mon tue wed thu fri sat 1234 567891011 12131415161718 19202122232425 262728 to allign first like under sunday there should be 1 under monday there should be 2
Ravi
#include<stdlib.h> #include <stdio.h> #include <stdbool.h> struct block { char theblock[5][4]; }; struct block blockArray[1]; int main(){ char answer; bool valid = true; char blocked_seats[2]; int reserved_seats = 0; struct block temp = { { {'A', 'B', 'C', 'D'}, {'A', 'B', 'C', 'D'}, {'A', 'B', 'C', 'D'}, {'A', 'B', 'C', 'D'},{'A', 'B', 'C', 'D'}} } ; blockArray[0] = temp ; printf("Available seats\n"); for (int i = 0; i < 5; i++){ printf("%d \t",i+1); for (int j = 0; j < 4; j++){ printf("%c \t",blockArray[0].theblock[i][j]); } printf("\n"); } while(valid == true){ int columnValue; printf("\nPlease enter seat code to reserve (1B,2A format)\n"); scanf( "%s", blocked_seats ); switch(blocked_seats[1]){ case 'A' : columnValue = 0; break; case 'B' : columnValue = 1; break; case 'C' : columnValue = 2; break; case 'D' : columnValue = 3; break; default : break; } int columnToBeBlocked = columnValue; printf("%d",columnToBeBlocked); char c = blocked_seats[0]; int rowToBeBlocked = c - '0'; printf("%d",rowToBeBlocked); if(blockArray[0].theblock[rowToBeBlocked-1][columnToBeBlocked] != 'X' && reserved_seats != 20){ blockArray[0].theblock[rowToBeBlocked-1][columnToBeBlocked] = 'X'; reserved_seats++; printf("seat successfully reserved\n"); for (int i = 0; i < 5; i++){ printf("%d \t",i+1); for (int j = 0; j < 4; j++){ printf("%c \t",blockArray[0].theblock[i][j]); } printf("\n"); } } else {printf("seat already taken!\n"); } if(reserved_seats == 20 ) valid = false; printf("\nDo you want to assign more seat? Y or N: \n"); scanf(" %c", &answer); if(answer == 'N') valid = false; } return 0; }
You can do following: Here are the booked seats: (prints the booked seats) Which seat yku want to cancle: (enters a seat number and validate it if it is booked or not, if it is then uodate that seat from booked to available and print successful)
Anonymous
Hello, who can say me good course of english?
Yorhane
Hello
Yorhane
good morning guys, I have a doubt, can I open an external .bat program in C?
Anonymous
What is the key difference between open source and application software?
Shourya
good morning guys, I have a doubt, can I open an external .bat program in C?
Open or run ?Use open call to open or system call to run..
Shourya
Run
Then check system ,exec calls
Yorhane
Then check system ,exec calls
in this case it will be on Windows
Anonymous
Problem: https://codeforces.com/contest/1539/problem/A My code: https://pastebin.com/hLdJTtuq Can someone tell me where I am going wrong?
Shourya
in this case it will be on Windows
Ok then try shellexecute call
Ravi
Problem: https://codeforces.com/contest/1539/problem/A My code: https://pastebin.com/hLdJTtuq Can someone tell me where I am going wrong?
You must use the mathamatics as the contraint is too high and you have used the loop. Try to calculate the answer directly
Yorhane
Ok then try shellexecute call
ok i'll try thanks
EDDIE
hello
EDDIE
How many problems do I have? Can you help me solve it?
EDDIE
about c++
Anonymous
How many problems do I have? Can you help me solve it?
How can anyone know how many problem u have? Is this a guessing game?
DarkSun
@IT_Trail
Yorhane
I have a doubt guys. which sites around us are in c/c++? can I develop on the web? I'm asking this question because I think c/c++ is very manageable
Anonymous
I have a doubt guys. which sites around us are in c/c++? can I develop on the web? I'm asking this question because I think c/c++ is very manageable
> which sites around us are in c/c++? client side - probably very few. but parts of a otherwise normal website may be written in C++ using WebAssembly server side - plenty in C, idk about C++ > can I develop on the web? yes. but you shouldn't aim to completely build the website in C++, instead augment the otherwise HTML/JS/CSS website with some C++ components. examples - on https://lichess.org/ the Stockfish engine (written in C++) runs on the client using WebAssembly libreoffice (written in C++) - https://wiki.documentfoundation.org/Development/WASM fully functional GUI apps may be written with - https://doc-snapshots.qt.io/qt6-dev/wasm.html
Anonymous
Problem: https://codeforces.com/contest/1539/problem/A My code: https://pastebin.com/hLdJTtuq Can someone tell me where I am going wrong?
It is just a simple problem of 3 cases: 1) t<x - Total dissatisfaction will be 0 in this case 2) t=x - Total dissatisfaction will be n-1 in this case there will be only 1 person who will start when he finishes his task. This will be the person next to him 3) t>x - In this case dissatisfaction count per person will depend on how big t is compared to x. If t<2x then dissatisfaction per person will be 1. If t<3x, then dissatisfaction per person will be 2 and so on. Once you calculate this, the answer for total dissatisfaction is easy.
Moses
Sorry how can I write and manage and http proxy in C
Mr.AL-Aramy
A program that prints employee data and salary in two ways: the first is according to his monthly salary and the second is according to the number of working hours and the price of one hour. This is by OOP. #include<iostream> using namespace std; class Emp { private: int ID; string Name; string Address; int Phone; public: void setInfo() { cout<<"\nEnter data\n"; cout<<"\nEnter the id: "; cin>>ID; cout<<"\nEnter the name: "; cin>>Name; cout<<"\nEnter the Address: "; cin>>Address; cout<<"\nEnter the phone: "; cin>>Phone; } void getInfo() { cout<<"\n The id: "<< ID <<"\n"; cout<<"\n The name: "<< Name <<"\n"; cout<<"\n The address: "<< Address <<"\n"; cout<<"\n The phone: "<< Phone <<"\n"; } }; class EMP_SAL: public Emp { private: double Salary; public: void setSal() { cout<<"\nEnter the salary: "; cin>>Salary; } void getSal() { cout<<"\n The salary: "<< Salary ; } }; class EMP_hours: public Emp { private: int NO_of_hours; double cost_hours; public: void setInfohou() { cout<<"\nEnter the number of job's hours: "; cin>>NO_of_hours; cout<<"\nThe cost of hour: "; cin>>cost_hours; } void getinfohou() { cout<<"\n The number of job's hours: "<<NO_of_hours<<"\n"; } void get_amount() { cout<<"\n The mount is: "<< (NO_of_hours*cost_hours); } }; int main() { EMP_SAL e; EMP_hours h; e.setInfo(); e.setSal(); cout<<"-------------------------"<<endl; cout<<"Display Data"<<endl; e.getInfo(); e.getSal();cout<<"$"; cout<<"\n\n&&&&&&&&&&&&&&&&&&&&&&&&&"<<endl; h.setInfo(); h.setInfohou(); cout<<"-------------------------"<<endl; cout<<"Display Data"<<endl; h.getInfo(); h.getinfohou(); h.get_amount(); cout<<"$"; cout<<"\n\n&&&&&&&&&&&&&&&&&&&&&&&"<<endl; }
𝔼𝕃𝔸𝕀𐇲
Guys when someone call u with ur name what is the polite way and impolite way to response 😙
𝔼𝕃𝔸𝕀𐇲
My English is weak and I am programming a bot 🙂💔💔
𝔼𝕃𝔸𝕀𐇲
Pradevel (Pratyush)
LOL 😭😭😭😭
Please go to the OT group for offtopic 😅
𝔼𝕃𝔸𝕀𐇲
Like really I need an answer 😭😭😭😭
𝔼𝕃𝔸𝕀𐇲
#ot
Thx 😊💜
Kwabena
Problem 4: Employees of a certain firm are paid on hourly basis. If an employee works for not more than 40 hours a week, the hours worked is considered regular and Overtime for hours worked beyond 40. Regular hours are paid at 5 cedis per hour while the overtime rate is one and half times the regular rate per hour. All employees are to pay 15% of their gross pay as Income Tax, 2.5% as National Health Contribution Levy, 1% as District Tax. Employees who have more than three children are to pay 50 pesewas per child in excess of three towards Educational Fund For All. Devise a computer solution that can be used to calculate the necessary deductions as well as the Net Pay of employees. Your display for each employee each deduction, net pay and the gross pay with appropriate captions
Kwabena
Clue
Anonymous
https://dpaste.org/P1Us Code for calendar in c language Working okok just a mistake that after printing -----------jan------- And week days the screen becomes blank for 40+seconds just want to remove the blank space from program
Anonymous
https://dpaste.org/P1Us Code for calendar in c language Working okok just a mistake that after printing -----------jan------- And week days the screen becomes blank for 40+seconds just want to remove the blank space from program
Check your get_1st_weekday logic. Perhaps you meant to apply %7 to the whole computation rather than just to the last bit. If I enter year as 2020, your get_1st_weekday returns 737425. You then print " ", 737425 times which will take a long time (the 40+ seconds that you are talking about).
@𝑺𝒐𝒃𝒌𝒂
Hi! Can someone recommend me some good books or websites for exercises or self challenge in C++?
Ojima
Hi all can I ask mql5 related questions here?
@𝑺𝒐𝒃𝒌𝒂
Où va le monde
Thanks
No much :)
Manav
https://pastebin.com/3fZ7r10Y
Anonymous
Can anyone suggest me for all the search sort algo and time complexity ..best explanation..video..
Viprr
Can anyone suggest me the best for c++