How Void Pointer behave differently in C & C++
Duration: 10 min
This video lesson is available to enrolled students.
Inside: a video lesson and guided study material.
Module outline
- Quantitative Ability: Speed Mathematics and Basic Mathematics, Percentage, Ratio and Proportion (Ratios), Average, Profit and Loss, Simple Interest and Compound Interest, Time and Work, Pipe and Cistern, Speed Time and Distance, Number System, HCF LCM, Data Interpretation, Age Problems, Mixture and Alligation, Partnership, Algebra, Sequence and Series (Series), Mensuration and Geometry, Arithmetic
- Reasoning Ability: Puzzle Solving (Puzzles), Seating Arrangements, Coding Decoding, Blood Relations, Directions (Direction Test), Syllogisms, Data Sufficiency, Ranking, Order and Sequence, Series (Number and Letter Series) (Numerical Relations and Reasoning), Logical Sequence Of Words, Calendar, Clock, Cubes & Dices, Analytical Reasoning (Counting Figures Reasoning), Data Arrangement, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning)
- Verbal Ability: Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Cloze Test (Cloze Passage), Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Vocabulary, Sentence Completion (Fill in the blanks), Active Passive Voice (Voice), Direct and Indirect Speech, Subject Verb Agreement (Verb Noun Agreement), Tenses, Preposition, Articles, Sentence Correction (Error Correction)
- Programming Basics (MCQs + Interview): C Programming by Yash Sir, Programming in C++, Java, Python for Placements by Yash Sir
- OOPs (MCQs + Interview): Object Oriented Programming (OOPS)
- DBMS (MCQs + Interview): Basics of DBMS, ER Diagram, Relational Model & Functional Dependencies, Keys & Integrity Constraints, Normalization (1NF - BCNF), Transaction Management, Decomposition Properties & 4NF, Concurrency Control, Database Recovery, File Organization & Indexing, Relational Algebra, Database Security & Authorization
- SQL (MCQs + Interview): SQL
- Operating Systems (MCQs + Interview): Introduction to OS, Process Management, CPU Scheduling, Deadlock, Threads & Process Creation, Memory Management, Virtual Memory, Process Synchronization, Disc Scheduling, File Management, Security
- Computer Networks (MCQs + Interview): Introduction to CN, Data Communication, DLL: Access Control, DLL: Flow Control, DLL: Error Control, DLL: Framing, Data Link Layer - Ethernet, Net Layer: IPv4 & Proto, Net Layer: IP Addressing, Net Layer:Routing Protocol, Transport Layer Services, TL: Congestion & UDP, Application Layer, Hardware basics, Network Security, Mobile Technology, Cloud Computing and IoT, Cyber and Info Security
- Coding: Coding Questions by Yash Sir
- HR Interview: MR & HR Interview Preparation
AI summary & chapters
AI Summary
An AI-generated summary of this video lecture.
This educational video, presented by Yash Jain from Knowledge Gate Eduventures, is a comprehensive tutorial on the application of void pointers in C and C++. The lecture begins with an introduction to the topic, using a title slide that displays the C and C++ logos and the text 'Application of Void pointer'. The instructor then transitions to a code-based explanation, presenting two code snippets side-by-side: one in C and one in C++. The core of the lesson focuses on the incompatibility between `void *` and `char *` pointers. The instructor demonstrates that in C++, a direct assignment like `char *ptr2 = ptr1;` where `ptr1` is a `void *` pointer will result in a compilation error due to the strict type checking. This is contrasted with C, where such a conversion is allowed implicitly. The video provides a practical demonstration using an online C++ compiler, showing the exact error message: 'error: invalid conversion from 'void*' to 'char*' [-fpermissive]'. To resolve this, the instructor shows the correct method: explicit type casting, writing `ptr2 = (char*)ptr1;`. The video concludes with a 'Thanks' slide, providing contact information for the course provider.
Chapters
0:00 – 2:00 00:00-02:00
The video opens with a title slide for a programming lecture. The slide features a dark background with green and white C++ code floating around. The main title is 'C++ PROGRAMMING' in large white letters, with 'By YASH JAIN' in the top right corner. The slide also includes a graphic of a computer monitor with the C and C++ logos and the text 'Application of Void pointer'. The instructor, Yash Jain, is visible in a small window in the bottom right corner. The slide also contains a copyright notice for 'KNOWLEDGE GATE EDUVENTURES' and a call to action to download the KG app or visit their website.
2:00 – 5:00 02:00-05:00
The video transitions to a code demonstration. The screen is split into two sections, each showing a C++ code snippet. The left snippet is labeled 'C' and the right is labeled 'C++'. Both snippets contain the same code: `#include <stdio.h>`, `int main()`, `{`, `void *ptr1;`, `char *ptr2;`, `ptr2 = ptr1;`, `return 0;`, `}`. The instructor explains that in C++, this code will not compile due to a type mismatch. He then writes on the screen, adding `char *ptr;` and `int *ptr;` to illustrate the concept of type casting. The instructor's voiceover explains that a `void *` pointer can point to any data type, but it cannot be directly assigned to a pointer of a specific type like `char *` without an explicit cast.
5:00 – 9:45 05:00-09:45
The instructor continues the demonstration, focusing on the C++ code snippet. He highlights the line `ptr2 = ptr1;` and explains that this is an invalid conversion. He then shows the correct way to perform the conversion by adding an explicit cast: `ptr2 = (char*)ptr1;`. The video then cuts to a screen recording of an online C++ compiler, where the instructor types the code and runs it, showing the compilation error: 'error: invalid conversion from 'void*' to 'char*' [-fpermissive]'. He then adds the cast, and the code compiles successfully. The video ends with a 'Thanks' slide, providing contact information for the course provider, including a Telegram group and an email address.
The video provides a clear and practical lesson on a fundamental concept in C++ programming: the use of void pointers. It effectively contrasts the behavior of C and C++ when dealing with type conversions, highlighting the stricter type safety in C++. The instructor uses a combination of visual aids, code examples, and a live coding demonstration to explain the problem and its solution. The key takeaway is that while a `void *` pointer can store the address of any data type, it must be explicitly cast to a specific pointer type before it can be used to access the data, a crucial rule for writing safe and portable C++ code.