top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

C++ : What is the difference when a function is defined within a class and outside class ?

+1 vote
479 views
C++ : What is the difference when a function is defined within a class and outside class ?
posted Aug 19, 2018 by Vikram Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Apart from difference of the syntax for defining functions (methods) within a class and outside class, When you define them within the class, C++ automatically makes them inline without explicitly mentioning it. While outside class definition of function doesn't makes it inline without prefixing with keyword 'inline' before the return type of the method in the header file for class

answer Aug 21, 2018 by 김홍숙
Similar Questions
0 votes

While doing design for a software, what things enforce to use template classes and template functions ?
Is it consider best practices or not ?

+2 votes

When a function is declared as virtual and when a class ? Please explain with examples.

0 votes

Given a Calendar class (there are three fields, year, month, day) and a number of N, Implement a function that returns the calendar after N days.

Example:
Input: {2017, 3,20} and 12,
Output: {2017,4, 1}

...