Declare & define user defined function inside a struct as we do in class - C++ basic concepts

Q.  In CPP program, Can we declare and define a user defined function inside a struct as we do in a class ?
- Published on 17 Jul 15

a. Yes
b. No
c. Can’t say

ANSWER: Yes
 

    Discussion

  • hansraj   -Posted on 12 Dec 16
    if u provess this information then the work of the mac book pro is not sufficient to work for process of ibn competing
  • Brijesh   -Posted on 07 Oct 15
    Yes we can declare and define a user defined function inside a struct as we do in a class.
    Example:
    struct Demo
    {
    void show()
    {
    cout << "Welcome at careerride.com"< }
    };
    void main()
    {
    Demo obj1;
    for(int i=0;i<5;i++)
    {
    obj1.show();
    }

    }

Post your comment / Share knowledge


Enter the code shown above:
 
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)