On 8/7/06, Gopi Krishna Komanduri <[EMAIL PROTECTED]> wrote:
This is the question I was asked in an interview.

You'll be wanting to quote from the Standard then.

ISO/IEC14882:1998

13 Overloading

When two or more different declarations are specified for a single name in the same scope, that name is said to be overloaded. Bu extension, two declarations in the same scope that declare the same name but with different types are called overloaded declarations. Only function declarations can be overloaded; object and type declarations cannot be overloaded.
 
In other words, it's not allowed. (Hope I've got the right part of the standard here...)

Paul Herring <[EMAIL PROTECTED] > wrote:
On 8/7/06, Gopi Krishna Komanduri <[EMAIL PROTECTED] > wrote:

Hi All,
           I have a class with name x and also a function ( independent of class) with same name. In main function I tried to declare an object for my class ( I thought we cann't assaign variable for a function with out declaring a prototype with typedef for a needed syntax). But I am getting error. Could any one of you explain what is the priority for memory allocation .
#include "stdafx.h"

void x()
{
    cout<<"Hai";
};
class x
{
public:
    x()
    {
    }
};
int main(int argc, char* argv[])
{
    x t;

class x t;

    return 0;
}


Why have you got a global function with the same name as a global class in the first place??



--
PJH

Into motorcycles? Need parts? Try www.gissit.com to contact lots of motorcycle breakers - free to use (UK based at the moment) __._,_.___

To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.




SPONSORED LINKS
C programming language Programming languages Computer programming languages
Java programming language


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to