/
yes and that pointer can't be null
And do you also know why some people says that it's better to use an object instance instead of a pointer
/
Because using reference more safe than pointer.
Do you also know what this code means Byte operator[](u32 address) const
Daulet
Do you also know what this code means Byte operator[](u32 address) const
reloading operator of index [ ]. In that case you getting byte by 32bit address
Daulet
And you don't know this
What you mean? Give me example
/
What you mean? Give me example
I don't know like static void main()
Daulet
I don't know like static void main()
google says that static function accessible only from file where that function declared
Unknown man
Because using reference more safe than pointer.
How using reference is safer than pointer as a question?
Pavel
How using reference is safer than pointer as a question?
1. Inside a function if you receive a reference, you know for sure it's not null, so you can't do nullptr dereference 2. You can't accidentally change address instead of value 3. You can't accidentally be passing const pointer to a mutable value instead of pointer to a const value
Pavel
Technically you can dereference a nullptr into a reference of course, but it's UB from that moment already, so no need to think about that inside the function
DaviChan
anyone here has used clang-query? I'm trying to define a matcher for const reference parameters. 🤔
DaviChan
and isConstQualified does not work since the reference is not directly const, but the const only applies to the value the reference is refering to
Jahongir
what does ?(question mark) operator do in c++
Anonymous
DaviChan
<condition>?<true>:<false>
DaviChan
if condituon is true, it will evaluate to <true>. Otherwise to <false>
DaviChan
example: int a = 2>3?4:5;
DaviChan
a will be set to 5
Anonymous
Amazing now I understand bro
Jahongir
thank you all so much
DaviChan
nice🔥
DaviChan
Sure, no worries. I'm thinking about making a playlist on youtube about C++. Would anyone here watch it? 🤔
Jahongir
ys
Anonymous
I'm a beginner in c programming somebody help me out to understand the basics so that I can apply in c++
DaviChan
Nice 🔥. I will think about what to cover and will link the playlist here once I uploaded the first video :3
DaviChan
When are you always Free
Mostly weekends and between 18:00 and 20:00 CET
DaviChan
😅
DaviChan
im like on the job 12h a day when i include traveling time. Kinda bad
Daulet
Who want to get C++ challenge
Dima
lol nice try to give out your assignment
Daulet
Who want to get C++ challenge
Its about C++ metaprogramming
DaviChan
Just ask ^^. Might have time later
DaviChan
Like templates or old school preprocessor stuff?
Kirillov
Who want to get C++ challenge
Make my course project for week
Daulet
Make my course project for week
Ha-ha what about this project
Daulet
lol nice try to give out your assignment
Task: Write array/vector where you pass to parameters dimension of array. Like array<int,3> arr. 3 - dimension
DaviChan
No, templates
So its really C? Just using a C++ compiler to compile :p 😂
DaviChan
Sorry, im not 100% sure if i got the task
Daulet
You need to do a basic reimplementation std::vector? 🤔
No. Universal template class that can turn to array with any dimension
Daulet
One exception. Dimension not bigger than 3
Daulet
Sorry, im not 100% sure if i got the task
I completed that task. That task helps understand a lot of C++ metaprogramming concepts
DaviChan
One exception. Dimension not bigger than 3
Is one allowed to use C++20 concepts?
DaviChan
If yes, its pretty straight forward. but it got me thinking how I would do it without
DaviChan
Well ofc. you can always just static_assert(T < 4)
Daulet
Well ofc. you can always just static_assert(T < 4)
I changed condition. You can make dimension larger than 3
Daulet
I changed condition. You can make dimension larger than 3
I found other solution for (dim > 3)
DaviChan
Okay 🤔
DaviChan
can't you just: <std::integral T, typename Q> class template_array final { Q* values; public: template_array(): values{ malloc(sizeof(Q)*T)}{} ~template_array(){ free(values); } };
DaviChan
ofc. define some geters and seters
DaviChan
Also not good. since it always heap allocates.
DaviChan
but its simple
DaviChan
Just a template parameter
Александр
Hello! Why do I have this message? -narrowing conversion of ... from 'int' to 'float'. Is it because I store values in {} braces?
DaviChan
No, you need to write the value as a float literal: 1.0f for example
DaviChan
initializer lists dont allow implicit convertions
Александр
So how do I write it in here? And furthermore, why isnt there the same warning in the tutorial? I have done everything the same. LinkRunData{0, 0, LinkRun.width/12, LinkRun.height}
DaviChan
Not sure what it expects, but 0 is an integer literal, so ypu would need to write 0.0f instead
DaviChan
Hope that fixed it. Need to go :) good night folks ✌
Deepak Chaurasia
#include <stdio.h> int factorial(int i); int main() { int f; printf("Program to do factors of a no.\n"); printf("Enter a no."); scanf("%d" ,&f); // Write C code here printf("the factorial of %d is %d", f ,factorial(f)); return 0; } int factorial(int i){ if (i ==1 || i==0){ return 1; } else{ return i* factorial(i-1); } }
Deepak Chaurasia
Giving null or wrong output,any problem in code?