Difference B/W range for Loop & foreach In C++?
HTML-код
- Опубликовано: 8 мар 2017
- JOIN ME
-----
RUclips 🎬 / @cppnuts
Patreon 🚀 / cppnuts
COMPLETE PLAYLIST
------------
C++ Tutorial For Beginners: • Introduction To C++
STL (Standard Template Library): • STL In C++
ThreadIng In C++: • Multithreading In C++
Data Structures: • Data Structure
Algorithms: • Binary Search
Design Patterns: • Factory Design Pattern...
Smart Pointers: • Smart Pointer In C++
C++14: • Digit Separator In C++
C++17: • std string_view in C++...
C++ All Type Casts: • static_cast In C++
INTERVIEW PLAYLIST
------------
C++ Interview Q&A: • Structural Padding & P...
C++ Interview Q&A For Experienced: • How delete[] Knows How...
Linked List Interview Questions: • Find Kth Node From Bac...
BST Interview Questions: • Search Element In Bina...
Array Interview Questions: • Reverse An Array
String Interview Questions: • Check String Is Palind...
Bit Manipulation Questions: • Find Set Bit In Intege...
Binary Tree Interview Question: • Invert Binary Tree
Sorting Algorithms: • Bubble Sort
C++ MCQ: • Video
C MCQ: • What printf returns af...
C Interview Questions: • Designated Initializat...
QUICK SHORT VIDEOS
-------------
C++ Short : • C++ Short Videos
C Short : • Shorts C Programming MCQ
In this video we see what is the difference between range based for loop and foreach loop in c++ programming language. For more details please watch full video and do let me know if there is any doubts in comment section.
#cpp #interviewquestions #programming #tutorial #coaching #beginners #computerscience #softwareengineering
This is wrong. You can use traditional arrays in for_each.
Run this code, it will work:
#include
#include
int main()
{
int arr[10];
for(int i=0; i
Thanks for correctly pointing it, I have to either shoot a new video or replace it.
Thanks man.
This comment should be highlighted.
Done, thanks..
Which is better to use(specially for
c++ containers like vector)?
You can use iterators on C-style standard arrays also. The following works.
#include
#include
int main()
{
int arr[10];
for(int i=0; i
Please make a video about the difference in the depth of this two iterating approaches
You can get iterators for arrays with std::begin() and std::end() functions.
But he says its not possible in traditional arrays not in std : : array !!.
good video,very helpful
Glad it was helpful!
Thanks I don't know about the second For sentence (int i:ar), it's similar to Python when we use for n in something.... Thanks anothert very interesting video...
:D
Hi, very informative tutorial. Please pause your video @5:54 for reference. I have a few questions. Can you kindly explain why have you used at Line 9: void print(int val) {cout
if you want to print the value in ar, you should do something like cout