zahra
Hello, excuse me, I have to implement a code whose algorithm is as follows: it seems that I have inputs in three dimensions and I want to consider these inputs as the center of the sphere and make these points fatter according to the radius received from the user. Can you guide me how I can write the code in c++ language?
Chat Boss
@MahmoudMartini sent a code, it has been re-uploaded as a file
محمود
How to make a class that accepts functions as parameters in the constructor?
zahra
if you know the algorithm you can just use your fav editor to write the code. Or am I missing something?
No, I have to come up with the idea of ​​the algorithm myself, and I wanted help from the programmers in this matter
محمود
How to make a class that accepts functions as parameters in the constructor?
#include <algorithm> using namespace std; class MyClass { function f; public: MyClass(function other) : f(other) {} } int main() { MyClass a(min), b(max); }
Chat Boss
How to make a class that accepts functions as parameters in the constructor?
@Kenshin_Dark_Knight_Himura sent a huge message, it has been re-uploaded as a file C++ provides several ways to do this, from function pointers, to function objects, to concepts, ..
محمود
Why that include? #include <bits/stdc++.h>
To include all the standard library. But as I remember it is only for GNU C++
Kenshin
To include all the standard library. But as I remember it is only for GNU C++
Exactly what I was getting at; it is not portable, and requires knowledge of the file storage structure. A portable way is to start using modules, and do, import std; Or, if you also want the global C functions, import std.compat;
Kenshin
I've edited: #include <algorithm>
If you want std::function, #include <functional>
Kenshin
But my main question was about the syntax of "functions as parameters in the constructor"
Yes, I understood your question. My response highlighted the several ways C++ allows you to do that. Your code was actually not entirely wrong; it is indeed one way, except std::function requires you to specify the signature of the function it will hold.
Kenshin
For example, std::function<int(string, socket)> fn; That will hold any free standing function that takes a string and socket and returns an int.
محمود
If you want std::function, #include <functional>
Here is a mini example to illustrate my problem.. I've put some question marks in the areas I don't know the syntax for: https://pastebin.com/sCTZv4WN
Kenshin
So you mean I should specify the type? In my example: std::function<int(int, int)> f;
If the function you will be passing in takes two ints and returns an int, yes. You are passing in std algorithms though, which are generic. Please give feedback.
محمود
If the function you will be passing in takes two ints and returns an int, yes. You are passing in std algorithms though, which are generic. Please give feedback.
I've used the std::function but the compiler tells me an error occur when calling the constructer: https://pastebin.com/BCN3aELj try.cpp|18|error: no matching function for call to 'MyClass::MyClass(<unresolved overloaded function type>)'
Kenshin
I just need int inputs and outputs
Yes, just specify the function signature.
محمود
Yes, just specify the function signature.
Can you point out where should I specify the function in my sample? I still can't get the syntax right. Thank you.
محمود
@Kenshin_Dark_Knight_Himura sent a code, it has been re-uploaded as a file
"wrapping it in a lambda" Interesting! I'll try it out
محمود
Thank you for your effort
محمود
@Kenshin_Dark_Knight_Himura sent a code, it has been re-uploaded as a file
It worked!! although it's a go around :) Thank you again for your help
Rose
Another one bites the dust...! Banned Toukour.
Rose
Purge complete.
Sandro
Hi! I've trying audio mixer SDL2 on Fedora & Ubuntu, after compiling a simple C source file with only SDL_Init(SDL_INIT_AUDIO) I will receive this msg from SDL_GetError(): dsp: No such audio device. I looking for msg on google but no solutions works.....
Sandro
Maybe some relation with pipewire?
how I can fix this issue?
Rose
User Anonymous-ALIAS has 1/2 warnings; be careful! Reason: offtop
Rachanatmak
Can we create a tally application from turbo c++ compiler? I asked the same question to My Al it replied it is difficult to create because turbo c++ is a older compiler .
VD
Can we create a tally application from turbo c++ compiler? I asked the same question to My Al it replied it is difficult to create because turbo c++ is a older compiler .
There is only one thing you can do with turbo c++. Install it on your system and invite your friends to view a really old software and charge them for it
Rachanatmak
There is only one thing you can do with turbo c++. Install it on your system and invite your friends to view a really old software and charge them for it
They don't pay because I'm a Computer Science student from 11th class this compiler is taught us in our classes ,so I only know how to use turbo c++ not other compiler.
Anonymous-ALIAS
User Anonymous-ALIAS has 1/2 warnings; be careful! Reason: offtop
Whoever did this probably did it by mistake, I didn't have to do it here.
Kenshin
Can we create a tally application from turbo c++ compiler? I asked the same question to My Al it replied it is difficult to create because turbo c++ is a older compiler .
Well, considering C++ has been used for decades to write some of the world's longest running or most complicated software, you probably can. However, the work you will have to put in will be unnecessarily tremendous, making the payoff a Pyrrhic victory. Advocate for a newer compiler and the use of modern C++ (at least C++20, or, if pressed, C++17). This Turbo C++ will do you no good, cause you will learn practices, idioms, libraries, and patterns that were long abandoned by the community.
Sandro
Maybe some relation with pipewire?
Finally I found the solution....the problem was that I've installed SDL2 manually with building the source.....I have uninstalled everything, than I reinstalling all by precompiled source from repos
Chat Boss
Andrey sent a huge message, it has been re-uploaded as a file Hello, let me please ask a simple question: int main() { std::vector<std::string>vec_; vec_..
Anonymous
/start@MissRose_bot
Rose
/start@MissRose_bot
Heya :) PM me if you have any questions on how to use me!
Anonymous
okay
Anonymous
how to start coding
harmony5 🇺🇳 ⌤
Rose
how to start coding
Please check out this channel - @Resources for information on learning sources for C and C++ (books and videos) and Frequently Asked Questions.
7008
Hello ! Are people here using qt ? i am currently making checkers using qt and c++ i want to integrate an IA(or any logical and mathematical functions) that will stand for the computer and play logically here is a sample
Chat Boss
7008 TONI sent a huge message, it has been re-uploaded as a file "class Damier : public QWidget { Q_OBJECT public: explicit Damier(QWidget *parent = null..
Chat Boss
7008 TONI sent a code, it has been re-uploaded as a file
mito
why bot doesnt tag users anymore ?
I assume, the user did not have a username.
Rose
Reported Herder Aberdeen [5714985745] to admins.​​​​​​​​​​​
Chat Boss
7008 TONI sent a code, it has been re-uploaded as a file
💙
Hi I'm a beginner at oop c++ So i wonder if it's acceptable to send the questions to this chat while i studying it ?
Rithesh
Hi I'm a beginner at oop c++ So i wonder if it's acceptable to send the questions to this chat while i studying it ?
Rithesh
I Wanna learn programming language
harmony5 🇺🇳 ⌤
dont ask to ask
It's the exact same msg as here: https://t.me/programminginc/517499 I wonder why they copied it, or maybe one is a bot?
Melvin ♣️
Give me some beginner projects in c++ so I can learn
Kenshin
Give me some beginner projects in c++ so I can learn
As always, Google, or your search engine of choice, is your friend, Search phrase was "beginner C++ projects github", https://www.google.com/search?q=beginner+C%2B%2B+projects+github&client=ms-android-transsion-infinix-rev1&sca_esv=594727199&ei=mEmRZaKYFc6jkdUPkfSHiAc&oq=beginner+C%2B%2B+projects+github&gs_lp=EhNtb2JpbGUtZ3dzLXdpei1zZXJwIhxiZWdpbm5lciBDKysgcHJvamVjdHMgZ2l0aHViMgUQABiABDILEAAYgAQYigUYhgMyCxAAGIAEGIoFGIYDMgsQABiABBiKBRiGAzILEAAYgAQYigUYhgMyCBAAGIAEGKIEMggQABiABBiiBEi5JFD8GFjHHnABeAGQAQCYAekCoAHqB6oBAzMtM7gBA8gBAPgBAcICChAAGEcY1gQYsAPCAggQIRigARjDBOIDBBgAIEGIBgGQBgg&sclient=mobile-gws-wiz-serp
Nan
Who can help me with downlaoding videos
Francesco
good morning everyone I wanted to ask if someone could give me a hand in solving the knapsack 0-1 problem via MPI and openMp , I have tried all of them but per se it seems imparallelizable as an algorithm , only reliable source of someone who succeeded is this article which also gives a little explanation but without being complete or going into implementation detail. https://ieeexplore.ieee.org/document/9396489
sspxktrxxm 🎵
Why does c++ use switch, case. when you can just use if and else?
nami
Why does c++ use switch, case. when you can just use if and else?
Too many if elses are not readable and mistakes are easier. I believe switch case can be faster don’t know the exact assembly tho
Rose
Heya :) PM me if you have any questions on how to use me!
Anonymous
Why does c++ use switch, case. when you can just use if and else?
It's a simpler way of solving the bulk task of if statements
Kurumi
Why does c++ use switch, case. when you can just use if and else?
In general, switch statements are slightly faster than if-else statements in C++. This is because switch statements are compiled into jump tables, which are optimized by the compiler to jump directly to the correct case label. If-else statements, on the other hand, are compiled into conditional branches, which can take slightly longer to execute. https://youtu.be/fjUG_y5ZaL4?si=nr18wz5vCjI1AnSV
nami
oh, ty
https://github.com/namiarj/zeptoshell/blob/main/src/zeptoshell.c Interesting use of goto and switch combined in this program
nami
It's not interesting, it's leg blowing
I appreciate your comment but if you can give details that would be better. This is of course not a working practical shell but I wanted to point out how it differs than if else
Rose
Purge complete.