C++ Basic problem

Mansi Munjal

Mansi Munjal

@mansi-munjal-5bqy46 β€’ Oct 22, 2024

Q:-1)Is there any difference between
Void getdata(void) and void getdata() in c++???
Q:-2)In C,
void display()-empty parantheses implies any number of argument.this is also true in c++???
pls reply

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Sanyam Khurana

    Sanyam Khurana

    @sanyam-Nl7Zqc Nov 1, 2014

    Mansi MunjalQ:-1)Is there any difference between
    Void getdata(void) and void getdata() in c++???

    No, if you specify void, it simply means that it requires no argument and would be equivalent to second form. And yeah, the first function would be void getdata(void) not Void getdata(void)

    Remember C/C++ is case sensitive.

    Mansi MunjalQ:-2)In C,
    void display()-empty parantheses implies any number of argument.this is also true in c++???
    pls reply

    I would first like to know how come this display() function can accept any no. of arguments in C?

  • Mansi Munjal

    Mansi Munjal

    @mansi-munjal-5bqy46 Nov 1, 2014

    i

    Sanyam KhuranaNo, if you specify void, it simply means that it requires no argument and would be equivalent to second form. And yeah, the first function would be void getdata(void) not Void getdata(void)

    Remember C/C++ is case sensitive.



    I would first like to know how come this display() function can accept any no. of arguments in C?

    i read somewhere that in C,if a function declared with an empty parentheses then in function definition we can pass any number of arguments.i want to know that is true in c++?

  • Sanyam Khurana

    Sanyam Khurana

    @sanyam-Nl7Zqc Nov 1, 2014

    Mansi Munjali

    i read somewhere that in C,if a function declared with an empty parentheses then in function definition we can pass any number of arguments.i want to know that is true in c++?

    Your concepts are absolutely wrong!

    Please tell me more about this Declaration and Definition thing.

    See, you declare a function so as to tell the compiler that this particular kind of function would be used.

    You define it, in order to implement the logic you want that module to execute.

    Empty parentheses means no arguments, and hence if declaration says your function would have no argument, then how can you define a function with arguments?

    It's just like saying Hello, My name is Mansi, I don't use internet.

    Then somewhere in definition you say, Hello My name is Mansi, I use CrazyEngineers.

    The declaration and definition goes hand in hand.

    PS: Please keep this explanation this time, I've my exams I would clear this entire thing after 10th! 😁

    Till then, why don't you use Google πŸ˜€

  • Mansi Munjal

    Mansi Munjal

    @mansi-munjal-5bqy46 Nov 1, 2014

    thanks for explaning...i get the point...@Sanyam