Ehsan
this how vectors are implemented
Ehsan
Anyway, I don’t think c is good with dynamic arrays. You should go to c++ as they have an efficient library called std::vector if you really want dynamic arrays.
Diego
Okay wait I think I'm missing something I know that array backed lists and vectors are implemented this way, but I had always understood malloc to be extremely cheap (albeit dangerous if done hazaphardly) And that the truly costly part of reallocating arrays was moving stuff over to the new one
Anonymous
Hi, I'm learning Qt and Qml and how to integrate them with c++ but I'm really confused, could someone give some advice?
Anonymous
connect QML with C++ you mean ?
yeah and about QML, it's a weird language
Anonymous
yeah and about QML, it's a weird language
https://doc.qt.io/qt-5/qtqml-cppintegration-topic.html
Anonymous
https://doc.qt.io/qt-5/qtqml-cppintegration-topic.html
I've read it but I'm still confused. Thx anyway
Anonymous
yeah and about QML, it's a weird language
qml is similar to java-script, good programming language for UI design. what wired ?
Anonymous
qml is similar to java-script, good programming language for UI design. what wired ?
I see it as a combination of HTML, CSS, JAVASCRIPT and it got a way of defining user-defined types
Ttfsefghh
What is the binary search working time algorithm?
Ttfsefghh
Is this O(n)
Anonymous
I've read it but I'm still confused. Thx anyway
write a class that inheritance from QObject and then write your functions that you need call from qml then register that on main function, import into qml file, like what said at documents. it's not very wired 🤔 get some example and do like that.
Anonymous
and I'm still confused about property binding
https://www.youtube.com/watch?v=e35ugcY2aOk
Anonymous
https://www.youtube.com/watch?v=e35ugcY2aOk
I just need to understand the mechanism of doing that. In other words, how is that allowed to happen, what's happening under the hood?
Phil
Polynome *polynome=NULL; polynome->p = malloc(counter*sizeof(Monom)); polynome->len=(unsigned int) counter;
Phil
this makes me an segamentation fault
Phil
clang doesn't warn me about any potentiel warining or error
Anonymous
I just need to understand the mechanism of doing that. In other words, how is that allowed to happen, what's happening under the hood?
I'm sorry for accurate explanation, but AFAIK all qml components are QObject classes (or inhertanced from that) defined in C++, so you just defining some other one and registering that in qml. (sorry for my English :)
Anonymous
so a ".qml" file is a class or "object" in c++?
No I don't think so. I meant QML components are C++ classes inheritance from QObject not QML itself or qml files.
Anonymous
No I don't think so. I meant QML components are C++ classes inheritance from QObject not QML itself or qml files.
yeah I got that, I meant like an item element and all its child elements in qml is a class or object in c++
Ehsan
Why did you do that?
AHMED
#include<iostream> #include<string> using namespace std; int main (){ string entered_password; cout<<"Enter your password:\n"; cin>>entered_password; string saved_password = "12gh34jk56"; if (entered_password == saved_password){ cout<<"You are allowed.\n"; } else{ cout<<"You are not allowed.\n"; } string data; cout<<"Enter some data:\n"; getline(cin, data); cout<<"You entered:\n "<<data; return 0; }
AHMED
The output:
AHMED
Enter your password: 12gh34jk56 You are allowed. Enter some data: You entered: [Program finished]
Anonymous
yeah I got that, I meant like an item element and all its child elements in qml is a class or object in c++
yes I guess so but I'm not sure. sorry. wait for someone's accurate explanation.
AHMED
Why does the getline function does not store my text?
Ehsan
Polynome *polynome=NULL; polynome->p = malloc(counter*sizeof(Monom)); polynome->len=(unsigned int) counter;
You tried to access an unitized pointer(which gives you segmentation fault).
Phil
Why did you do that?
clang said me to do that
Anonymous
Phil
@kyoko687 can we continue in a hour ? I have something to do right now sorry
Phil
clang said me to do that
poly2.c:28:2: warning: variable 'polynome' is uninitialized when used here [-Wuninitialized] polynome->p = malloc(counter*sizeof(Monom)); ^~~~~~~~ poly2.c:27:20: note: initialize the variable 'polynome' to silence this warning Polynome *polynome; ^ = NULL
Ehsan
@kyoko687 can we continue in a hour ? I have something to do right now sorry
You need to understand how malloc works. Please refer to the docs: https://www.cplusplus.com/reference/cstdlib/malloc/ Or search in YouTube. I cannot explain complex subject in the chat.
Phil
ok thak you for your help !
MAC
It's even better when you learn C++ without knowing C
Hmm, I don't agree with you, there are lot of functions from C , lot of new operators that based on C
Ehsan
ok thak you for your help !
Also this will help: https://en.m.wikipedia.org/wiki/Pointer_(computer_programming)
Anonymous
Watch this talk
Ehsan
It's even better when you learn C++ without knowing C
Actually no, c++ has so many extra things that makes it pretty confusing(for beginners). If you understand c pretty will, c++ will be a breeze.
Phil
thanks all for help
Anonymous
MAC
#stop_teaching_c_as_cpp_preamble
Simple example is operator new that contains malloc
MAC
I’m not my opinion :)
you can't , if it's wrong opinion 🤣
Anonymous
Show me a standard paragraph where it stated that operator new calls malloc
MAC
Show me a standard paragraph where it stated that operator new calls malloc
you can find it in book "system programming in Linux" Robert Love
MAC
It's not C++ :)
? There have explanation about malloc in a chapter and also mention new
Anonymous
If you say something about C++ it should be correct according to the C++ Standard, not a random book
Anonymous
Ok if you know then explain me how does it work ?
Why would I? It's part of implemention
Anonymous
You don't understand how CPU works but you still use it
Anonymous
Does anyone know what compiler supports c++20, and whether Cmake supports it or not? I've done some research but I didn't get a clear answer. I'm starting a new project and I need to know if I can use modules, contracts, etc.
Anonymous
you can find it in book "system programming in Linux" Robert Love
It's compiler designer assignment how implement new and delete, It hasn't a standard definition.
Anonymous
It's compiler designer assignment how implement new and delete, It hasn't a standard definition.
It's better to say: It has a definition (what it should do) but doesn't have a standard implementation
Anonymous
There's no contracts in C++20
what about the rest? can I use them
Anonymous
what about the rest? can I use them
You can do whatever you want! https://en.cppreference.com/w/cpp/compiler_support
Anonymous
CMake doesn't support modules afaik
Anonymous
Anonymous
what build system does?
I don't know
Anonymous
You can do whatever you want! https://en.cppreference.com/w/cpp/compiler_support
Ther is partial support for some features like modules. can I still use them without any problems?