BinaryByter
MᏫᎻᎯᎷᎷᎬᎠ
You can just loop it
Yeah That was just explaination
MᏫᎻᎯᎷᎷᎬᎠ
How can I not do it?
If you have a known size you can do that safely without touching non-ralated areas
Dierry
On parle pas ici?
Dima
English only
olli
I am trying to do this because I am trying to save myself from doing class1.set(5) class2.set(5) class3.set(5) Whenever something in a UI happens. It would be much cleaner to have to just have a base class that acts as driver and modifies the code if they depend on each other. Say one class is an OpenGL setter function, one class is a textBox that waits for input, and another is a slider that adjusts color. And that slider affects the openGL call and the input of the text box. And maybe I have more than one slider. See the issue now? Everytime I have to make an update I have to update those things within a code manually. This can get ugly and complex really fast. So I am trying to simplify things into just one base that can handle all of this when an update happens. This class will only know of the getter and setter functions. That's it. So I am trying to wrap them into a class without having to do: update (int value) { ui->mySlider->setValue(value); ui->myTextBox->setValue(value); GLClass->setValue(value); ... // More objects to set } Instead it would be nice to just modify what is necessary. update(ui->mySlider, GLClass,value) { BaseClass<ui->mySlider,GLClass> base; base->setValue(value); }
something like this? template <class T1, class Value> void setAll(const Value& value, T1& t) { t.setA(value); } template <class Value, class T1, class... T2> void setAll(const Value& value, T1& t, T2&... t2) { t.setA(value); setAll(value, t2...); } Usage: A a; B b; setAll(3, a, b);
olli
Something like that, but I figured it out without being dumb about it I think. However I think your way is more clever. Does the set all take an arbitrary amount of classes in it?
yes, (but at least one). you can also use template <class Value, class... T> void setAllValues(const Value& value, T&... t) { using expander = int[]; (void)(expander{ 0, (t.setA(value), 0)... }); }
Raul
Can you link expander? I do have access to 17
olli
Can you link expander? I do have access to 17
I just figured you don't even need 17.. expander is just a type alias (first line of the function body) this would require 17 template <class Value, class... T> void setAll17(const Value& value, T&... t) { (t.setA(value), ...); }
Dima
Read the rules first
Dima
No photo of screens
Anonymous
No photo of screens
What is that 😅😅
Anonymous
/notes
olli
How to create a Minimal, Complete, and Verifiable example When asking a question about a problem caused by your code, you will get much better answers if you provide code people can use to reproduce the problem. That code should be… …Minimal – Use as little code as possible that still produces the same problem …Complete – Provide all parts needed to reproduce the problem in the question itself …Verifiable – Test the code you're about to provide to make sure it reproduces the problem https://stackoverflow.com/help/mcve
MᏫᎻᎯᎷᎷᎬᎠ
#include <iostream> struct base{ virtual void test(){ std::cout << "calling base\n"; } virtual ~base(){} }; struct derive1 : base{ void test(){ std::cout << "calling derive1\n"; } }; struct derive2 : derive1{ void test(){ std::cout << "calling derive2\n"; } }; int main() { derive1* d1 = new derive2(); d1->test(); delete d1; } I just wanted to ask I know all these stuffs about virtual function, vitable....etc thanks to @ollirz but I'm confused with something here in the code above I didn't mark test() method in derive1 struct with virtual for learning reasons(not for good practice reason) i want to limit the virtuality of test method on just derive1 means that if I typed derive1* d1 = new derive2; d1->test() it must output: "calling derive1" you get it? but the output from the above code is: "calling derive2" so I got confused to be honest I hope you got my question thanks
MᏫᎻᎯᎷᎷᎬᎠ
anyway That's not the question
MᏫᎻᎯᎷᎷᎬᎠ
so there is no way to limit the virtuality of a function
MᏫᎻᎯᎷᎷᎬᎠ
Once a function is virtual it stays virtual. If you want child classes not to override your virtual function(s) again/any more mark them as final. (requires C++ >= 11) struct derive1 : base{ void test() final { /* */ } }; would result in a compile error, since you try to override the final virtual function test in derive2
I wanted the child to override the function but not to be called if it was passed as another function arguement like void foo(derive1* d){ d->test(); } void foo1() { foo(new derive2); //i want to call derive1 test not derive2 } even if it's a design error I just wanna know how (if that is impossible)
olli
so there is no way to limit the virtuality of a function
you can only prevent derived classes to override the funtion again
olli
why would someone strict final to a virtual function?!
- it could increase performance, since indirect calls can be eliminated in some cases. - Depending system you have a implementation in a base class that you want a derived classes to inherit from. So they either choose to implement all the functions of the interface themselves or they "agree" to use the final implementation
Anonymous
/notes
Anonymous
So what is a template in C++?
Anonymous
#ide
MᏫᎻᎯᎷᎷᎬᎠ
So what is a template in C++?
Templates - cppreference.com https://en.cppreference.com/w/cpp/language/templates
Anonymous
/notes
Dima
/ban No!
Dima
/get ossu
Anonymous
Dima
Indeed, have a good night
Anonymous
Hello
Mal
/notes
Anonymous
# cpp
Aurora
aaaaa
#define CLEAR_BUFFER while ( getchar ( ) != ’ \n ’ )
hello here, who competes to google code jam ?
Anonymous
How to crawl https in C++ ?🤔
Jussi
How to crawl https in C++ ?🤔
what do you mean by "crawling"?
Jussi
you should understand the principals of https and networking in general. The https traffic is encrypted between the server and the application end points. If you try to "crawl" in between them, you simply cannot.
Anonymous
yes http i can but https I don't know what to do
Jussi
you should look for guides on "how to sniff https traffic"
Jussi
but this is not C/C++ related so,
Anonymous
pythaon Seems easy - - !!!!
Andrei
I crawled a https site once in bash, just needed a html parser and used pup, why wouldn't crawling work on https?
Mat
what do you mean by "crawling"?
https://en.wikipedia.org/wiki/Web_crawler
Mat
I think he was talking about this crawling
Jussi
isn't that then web/html crawling :)
Anonymous
yes
Anonymous
OpenSSL seems to be able to do that
Anonymous
I'll try🙈
Anonymous
Goodmorning people! Wanna ask if there is currently any programming competition for students in europe😁👍🏾
Anonymous
For sure :)
🙂can you tell me the names of the ones you know about? Thanks.
aj
Iam just doing practice friends and not a class activity/homework
aj
As a beginner to cpp,sorry for that admins and I request to be removed from 2 warns
BinaryByter
We will not remove your 2 warns
BinaryByter
however, they shouldn't pose a problem to you as long as you behave well
Mike
/ot
Dima
Lol
Anonymous
Anonymous
Some one please help me ?
Anonymous
What is written in those brackets?
Anonymous
do you know the logic?
BinaryByter
iomanip is your friend
BinaryByter
whats up with those dots
BinaryByter
Lunatic used to write them, now you
BinaryByter
is it the group's bufoon who dots around like crazy?
Anonymous
Non negative integer
BinaryByter
whack punchline
Dima
.
Anonymous
Anonymous
Non negative integer
Anonymous
Guys what about the question
D
Any way to watch a matrix for changes ?? And trigger events on that in C ?
D
Like adding a int to a matrix or uodation an delettion ??