piggyho
So basically you are saying that sometimes passing by value for small size type is slower than by reference?
because an int passed by ref is treated internally as a pointer. therefore when you access that integer you're doing of one level of indirection to get to the value of the pointer
Akhil
Respected Sir/Madam Can I get the software copy for turbo C++ for windows 7 ? Please message me personally
Dima
Looooool
devil
How to motivate myself to learn coding
barungh
Noor
*HELP* how to add system installed library like pthread ncurses in cmake?
piggyho
How to motivate myself to learn coding
it's fun, no motivation needed ¯\_(ツ)_/¯
Pasha
int* ptr; ptr[0] = 13; // What will be the answer for this if I try to print ptr
Pavel
int* ptr; ptr[0] = 13; // What will be the answer for this if I try to print ptr
ptr or *ptr? ptr will be some random address in memory. *ptr will be 13
Anonymous
Hey guys need help
Anonymous
Beginner in c
Anonymous
Which ide I start from
Pavel
vi/vim/nvim
Anonymous
Hy
Pavel
Or vscode
MᏫᎻᎯᎷᎷᎬᎠ
So this is from Effective C++ book the question is why "As long as you don’t take the address" the compiler won't insist or complain, what's wrong with that? their address"
Coding
/getfreeprogrammingbook
Anonymous
I've done that
MᏫᎻᎯᎷᎷᎬᎠ
Yeah that's what the book says, but why You can get the value of the static variables but you can't get their addresses?!
MᏫᎻᎯᎷᎷᎬᎠ
Okay Now I get it Thanks Madhu
.
#freeprogrammingbooks
Anonymous
Is there any way by which I can get the size of an array in a function where the array received as an argument?
Vlack
Hi, I'm a beginner in c++, my books don't help much, is there a website or something from where I could learn c++ for free? Any suggestions ? Thanks 🤏
Vlack
/notes
Vlack
#cppbookguide
MᏫᎻᎯᎷᎷᎬᎠ
Hi, I'm a beginner in c++, my books don't help much, is there a website or something from where I could learn c++ for free? Any suggestions ? Thanks 🤏
Just skim through the blogs, references, projects, ask for syntax that you don't understand or you've first saw Be curious, ask any question that comes into your mind, always try to understand everything about what you've learned Don't be afraid from looking like a dumb before other programmers, you are not And finally know that there devs who just want to show off their skills and how good they are, they just tell you don't do this, do that packed with a lot of info and reasons and they know you won't understand a single word, those are the bad guys don't take them seriously
MᏫᎻᎯᎷᎷᎬᎠ
Another one last thing Google is big-guru around here
Vlack
Thanks a lot 😊 👍
MᏫᎻᎯᎷᎷᎬᎠ
You're welcome :)
Vlack
But is there any one source I can follow to atleast become an intermediate in c++
MᏫᎻᎯᎷᎷᎬᎠ
Vlack
I study in a college where teachers ask us to mug up programs and puke on the papers, and this is my last year of school, and I don't fail
MᏫᎻᎯᎷᎷᎬᎠ
Yes exactly..
What exactly? :)
Alex
Hello. I would like to know about experience of professional developers: do you always use std::array over c-array? in what cases do you choose one of alternatives?
Vlack
A book to develop my fundamentals, how do I make my thoughts dynamic when I try to write codes
...
there are teachers who will ask you to "find every error in this source code" and then give you a bad grade because the errors you marked are not the ones they were searching for; you're playing in a casino at that point
MᏫᎻᎯᎷᎷᎬᎠ
Hello. I would like to know about experience of professional developers: do you always use std::array over c-array? in what cases do you choose one of alternatives?
Nearly everything Always prefer std::array over c-style one std::array has a lot of member functions that helps you a lot and it goes with stl library like begin() and end() The most important you know the size() C-style one is just a pack of array with no metadata
Vlack
My class teachers are so irritating, they teach a concept in such a way that I keep scratching my head and later get fed up of c++, I've got a bad feeling ill flunk
Vlack
And in this pandemic, everything is even more screwed up 🙁
MᏫᎻᎯᎷᎷᎬᎠ
A book to develop my fundamentals, how do I make my thoughts dynamic when I try to write codes
I'm not sure what are you talking about but I always suggest for newbies to go for "Jumping into C++" it's for C++11 but it will teach a lot
Vlack
Geeksforgeeks
Thank you too @MeEtJaNi
MᏫᎻᎯᎷᎷᎬᎠ
what about two dimensional array?
std::array<std::array<int, 5>, 5> arr;
MᏫᎻᎯᎷᎷᎬᎠ
Alex
std::array<std::array<int, 5>, 5> arr;
I know :) I mean do you always use it over int arr[5][5] or int arr[5*5]
Alex
cause syntax is quite awkward
...
cause syntax is quite awkward
why do you think its awkward?
Alex
why do you think its awkward?
try to declare this in std:array: int arr[5][5][5][5]
...
true, but tbh, i used arrays with more than 2 dimensions maybe like 2-3 times the past 6 months, and most of the time you *could* work arround that and most likely get a better solution.
Pavel
How can I set (double*) buffer to zero?
Vlack
@bond00_7 Brother, I can't find any free ebooks or PDFs for Jumping into c++
Alex
Yes
how to pass data from multidimensional std::array to C API void func(int arr[5][5])?
MᏫᎻᎯᎷᎷᎬᎠ
@bond00_7 Brother, I can't find any free ebooks or PDFs for Jumping into c++
Yes It's not free I'm not sure about a free book out there
Pavel
std::memset?
Will it be OK? I mean, 4 zero byte sequence is equal to 0.0, right?
Alex
array.data() should work
#include <iostream> #include <array> using namespace std; void func(int arr[5][5]) { } int main() { array<array<int, 5>, 5> arr; func(arr.data()); return 0; } g++ -std=c++11 ./test.cc ./test.cc: In function ‘int main()’: ./test.cc:13:20: error: cannot convert ‘std::array<std::array<int, 5ul>, 5ul>::pointer {aka std::array<int, 5ul>*}’ to ‘int (*)[5]’ for argument ‘1’ to ‘void func(int (*)[5])’ func(arr.data());
Alex
try func((int(*)[5])arr.data());
thank you. so we have awkward syntax, and to cast multi std::array. also there are extra brackets for initializing https://stackoverflow.com/questions/17759757/multidimensional-stdarray but still better choice than C array
...
Very bad
what would a c++ style cast change here?
Anonymous
what would a c++ style cast change here?
Nothing, it wouldn't compile Casting std::array to c-array is bad
Anonymous
Actually I think using the casted value is UB
...
so maybe read what kind of a problem they were facing?
Anonymous
Wat?