Function Defined Outside the Class

Duration: 9 min

This video lesson is available to enrolled students.

Return to /learn/BIHAR-POLYTECHNIC-LECTURER-COMPUTER-SCIENCE/paper-1-programming-language/oops-with-c/reference-variables-member-functions-inlinestatic/asset-function-defined-outside-the-class after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Discrete Mathematics: Permutation, Combination and Probability / क्रमचय, संचय एवं प्रायिकता, Set Theory, Relations, Functions, Propositional and Predicate Logic, Graph Theory, Group Theory
  2. Digital Logic: Digital Systems & Boolean Basics, Boolean Expression, Boolean Minimization, Logic Gates & Hardware, Combinational Circuit, Sequential Circuits, Number System, Number Representation, Floating Point Rep
  3. Computer Organization and Architecture: Basics of COA, Programming the Basic Computer, Cache Memory Organization, Input Output Organisation, Instr Formats & Modes, Register Transfer and Microoperations, Control Unit Design, Pipelining, Multiprocessors
  4. Programming: Language Design, C Fundamentals, Control Flow, Functions, Arrays & Pointers, Storage Classes, Structures & Enums, DMA, Macros, Scoping & File Handling, OOPS with C++
  5. Data Structures: Introduction to DS, Array, Linked List, Stack, Queue, Tree, Graphs, Hashing
  6. Algorithms: Algorithm Analysis, Time Complexity Analysis, Sorting Algorithms, Greedy Algorithms, Dynamic Programming, Minimum Spanning Trees, Shortest Path Algos, Advanced Algorithms
  7. Theory of Computation: Grammar, Regular Language Properties, Moore & Mealy Machines, Turing Machines
  8. Compiler Design: Intro to Compilers, Lexical Analysis, Grammar & CFG, Syntax Analysis: Top-Down, Syntax Analysis: Bottom-Up, Semantic Analysis & SDT, Intermediate Code Gen, Code Optimization, Run Time Environment, Introduction to TOC, Deterministic FA (DFA), Non-Deterministic FA, Regular Expressions, Pushdown Automata & CFG, Complexity Theory
  9. Operating Systems: Introduction to OS, Process Management, CPU Scheduling, Process Synchronization, Threads & Process Creation, Deadlock, Memory Management, Virtual Memory, Disc Scheduling, File Management, Unix OS, Linux OS, Security
  10. Database Management Systems: Basics of DBMS, ER Diagram, Relational Model & Functional Dependencies, Keys & Integrity Constraints, Normalization (1NF - BCNF), Decomposition Properties & 4NF, File Organization & Indexing, Relational Algebra, SQL, Relational Calculus, Transaction Management, Concurrency Control, ORDBMS, NoSQL
  11. Computer Networks: 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
AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This lecture segment focuses on defining member functions outside their class declarations in C++, specifically examining the role of the 'inline' keyword and common compilation errors. The instructor begins by contrasting two valid scenarios: defining a function without 'inline' versus with it, demonstrating that both compile and execute successfully. The lesson then progresses to invalid cases where mismatches in return types, const qualifiers, class scope, or parameter types cause compilation failures. Visual cues such as red circles and compiler error messages are used to highlight specific syntax violations.

Chapters

  1. 0:00 – 2:00 00:00-02:00

    The instructor introduces the topic of defining functions outside a class, presenting two valid cases side-by-side. Case 1 shows a function defined without the 'inline' keyword, labeled as a normal member function. Case 2 shows the same function defined with 'inline', treated as an inline member function. Both snippets include '#include<iostream>' and a class declaration 'class temp' with 'void print();'. The instructor emphasizes that omitting or including 'inline' does not prevent compilation, as both produce the output 'Hello from print()'. On-screen text confirms 'CASE 1: Missing inline - No Error' and 'CASE 2: With inline - No Error', establishing that both approaches are syntactically valid.

  2. 2:00 – 5:00 02:00-05:00

    The lecture transitions to error cases, starting with Case 3 where the return type in the definition does not match the declaration. The code shows a function declared as 'void' but defined returning 'int', triggering error C2556. Case 4 introduces a missing const qualifier, where the declaration includes 'const' but the definition omits it. The instructor uses red circles to highlight these mismatches, and Visual Studio displays error C2511 for overloaded member functions not found. The text 'Return type in definition (int) does not match declaration (void)' and 'Function is declared with const, but defined without const' appears on screen to clarify the specific violations causing compilation failure.

  3. 5:00 – 8:42 05:00-08:42

    The final segment covers two additional error scenarios. Case 5 demonstrates a 'Wrong Class Scope' error where the function is defined for class 'test' instead of the declared class 'temp'. Case 6 shows a 'Different Parameter Type' error, where the definition uses a float parameter while the declaration expects an int. The instructor points out these discrepancies using arrows and red circles, with on-screen text stating 'The parameter type in the definition (float) does not match the declaration (int)'. Both cases result in compilation errors, reinforcing that function definitions must strictly adhere to the declaration's signature and class scope.

The video systematically builds understanding of C++ member function definitions by first validating correct syntax before introducing common pitfalls. The core concept is that while 'inline' affects optimization behavior, it does not change the requirement for matching declarations. The progression from valid cases to error cases helps students identify specific syntax rules: return types must match exactly, const qualifiers are mandatory if present in the declaration, class scope must be consistent, and parameter types must align. The use of compiler error messages like C2556 and C2511 provides concrete evidence of what the compiler expects, making these rules memorable for exam preparation.

Loading lesson…