AHMED
Better solution just is using regular int. Why do you need pointers and new?That's the the reason your code leaks memory now
Please note that the default copy constructor does not correctly copy members of some types, such as pointers, arrays, etc. In order to properly make copies, we need to define our own copy logic inside the copy constructor. This is referred to as a deep copy. For pointers, for example, we need both to create a pointer and assign a value to the object it points to in our user-defined copy constructor
AHMED
I was trying this Igor.
AHMED
Ok. I will take this into account in the next lesson.
AHMED
Thank you 😊
🕸 03xploit 🕸
Hi everyone Can anyone help me ? I want send random http request to many url Please help me What make url list ? Making list or array and etc ??
ASV
Hello all
ASV
Anyone here is well versed with iOT?
ASV
Need some help please buzz me
ASV
my job relies heavily on the completion of this project
ASV
🙏🏻🙏🏻
Hanz
ASV
anyone here have experience with Heltec ESP32 LoRA V2 chip?
ASV
using Arduino IDE?
ASV
Here’s the situation... 1) i have to develop a turbidity sensor using Heltec ESP 32 LoRA V2 using Arduino IDE... 2) problem is I’m only good with python and have no experience with C++ 3)anyone here willing to guide me just a bit on setting up the sensor and the reading on the display ?
nelnel
/get cbook
Gulnar
Hello everyone one. I wanna write a program for unit conversation. From inch to centimeter. I can convert, but this time I couldn't get the unit after the number. How can I write it?
armandofsanchez
/get cbook
Gulnar
C or C++? How do you output the number?
I have written float centimeter = 2.54*(float)inch. But I want also to add unit of inch and centimeter, how can I do this?
Chinepun💛
Does anyone know a tutorial on OpenGL ES with Android studio
𝙑𝙚𝙙𝙖𝙣𝙩
/rules
Ajit
/rules
Global Hub Educational consultancy
Do anyone have books related to javascript language
AHMED
#include <iostream> #include <string> #include <iomanip> using namespace std; class patient { public: int id; string name; patient(int a, string b) : id{a}, name{b} { cout << "User-defined constructor invoked.\n"; } patient(patient &&ex) : id{move(ex.id)}, name{move(ex.name)} { cout << "Move constructor invoked.\n"; } }; int main() { patient patient1(123, "Ahmed"); cout << patient1.id << "\n" << patient1.name << endl; cout << "===============\n"; patient patient2{move(patient1)}; cout << patient2.id << "\n" << patient2.name << endl; cout << "===============\n"; cout << patient1.id << "\n" << patient1.name << endl; }
AHMED
After calling the move constructor, the member variables in patient1 should be empty. Why the last call of patient1.id prints 123 ?
AHMED
This is the output:
AHMED
User-defined constructor invoked. 123 Ahmed =============== Move constructor invoked. 123 Ahmed =============== 123 [Program finished]
Anonymous
After calling the move constructor, the member variables in patient1 should be empty. Why the last call of patient1.id prints 123 ?
> patient1 should be empty there is no reason for that on a low level language like C++.
Anonymous
you are probably thinking about the concept of nullable types
H
and because of that sometimes we see UB 😂😂
Pavel
After calling the move constructor, the member variables in patient1 should be empty. Why the last call of patient1.id prints 123 ?
There are no guarantees for the moved-from object state except that it can be safely destructed. As was mentioned, not setting int to zero is faster than setting it to zero. And not setting it to zero is correct from the point of move semantics.
Ishikawa
TLDR; What is the most native approach to drawing GUIs, one which is independant of OSs and APIs ? Hello everyone ! I'm currently learning C and have only used command line to build and execute. It wad really curious to know how graphics works. I've been researching lately and found out about the APIs and everything. It makes me wonder what is the most native approach to drawing GUIs.
Generation Z
/rules
Pavel
klimi
Bruno
have you had a look at GTK? ._.
Yeah, most used for high level languages line python, JS and specially Vala
Codigo
Guys, I have a question. Why would some users.prefers C over Ada, or Ada over C?
Vlad
Next question
klimi
In C we Trust
Nameful
In C we Trust
Trusting C sounds like a bad idea
klimi
Trusting C sounds like a bad idea
My algorithm is bad idea
Igor🇺🇦
Why the hell pure C is not used for GUI? >.<
Why would anyone use C over C++ especially for GUI? OOP style code suits GUI very well.
Bruno
Why would anyone use C over C++ especially for GUI? OOP style code suits GUI very well.
Yes, OOP was created for GUI programming, but why not just C?
Anonymous
No RAII makes language horrible
Anonymous
No function overload
Anonymous
No incapsulation
Vlad
Yes, OOP was created for GUI programming, but why not just C?
You can do gui in C but it shall be pain the arse. And why would you anyway
Pavel
Why the hell pure C is not used for GUI? >.<
Pure C and good GUI libraries operate on too distant levels of abstractions. In order to implement a standard gui library it will require to standardize the whole lot of things in-between these levels. Not only it's a lot of effort but also I think it will make the language more complex.
Igor🇺🇦
Yes, OOP was created for GUI programming, but why not just C?
OOP wasn't created for GUI. It just easier to translate GUI elements to objects like widget, dialogs, bars etc. The major C GUI library like Gtk is emulating OOP in C. https://en.wikipedia.org/wiki/GObject. So why not use proper OOP language to begins with? And C++ has lots of other advantages as well over C.
SHIKWAYA
Evening guys... I'm currently pursuing in electrical engineering and i need help in starting to learn how to programme with the C languages
klimi
Why would anyone use C over C++ especially for GUI? OOP style code suits GUI very well.
If you look at C and C++, I think you do see reasons why do C
Nameful
My algorithm is bad idea
Klimi's Algorithm
Igor🇺🇦
If you look at C and C++, I think you do see reasons why do C
Sorry, but I did not understand that sentence.
klimi
Sorry, but I did not understand that sentence.
If you look at the programming language C and the programming language C++, you will see reasons why would one prefer C over C++
Igor🇺🇦
If you look at the programming language C and the programming language C++, you will see reasons why would one prefer C over C++
From my experience it's the other way around. C++ is more readable code especially when working with large code bases. You use higher level abstractions and less boilerplate code.
SHIKWAYA
i'm trying to download it but id doesn't want at all
Igor🇺🇦
Yeah but you lose performance and it is more difficulty to learn
No you're not losing performance. You have the same level of low level access as C. And I bet std library implementation is better than whatever internal library generic company can write.
Vlad
Maybe virtual functions and what not
Vlad
But you can always not use them lmao
klimi
Not much but it is there
Igor🇺🇦
Yeah but you lose performance and it is more difficulty to learn
And I disagree that C++ is more complicated to learn. It's much easier to start writing and reading C++ and than C. Learning C++ in depth is hard, but it's not necessary to know everything to be productive.