From: krishna_sicsr [mailto:[EMAIL PROTECTED] 

>Hello friends,
>        I want to know why the statement class a *a; valid in main 
>and what is the meaning of this in c++ 

It should not be valid - your compiler should be complaining about it -
That is if you mean using a variable name the same as a class name:

$ type cpp.cpp
#include <iostream>
using std::cout;

class foo{
    public:
        foo(){cout << "foo::foo()\n"; }
        ~foo(){cout << "foo::~foo()\n"; }
        void bar(){cout << "foo::bar()\n";}
};
int main(){
    class foo* foo = new foo;
    foo->bar();
    delete foo;
    return 0;
}

$ make
cl cpp.cpp /EHs /Zc:forScope /Wall /W4 /WL /wd4820 /wd4619 /wd4217
/wd4710 /wd4668 /c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for
80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

cpp.cpp
cpp.cpp(11) : error C2061: syntax error : identifier 'foo'
make: *** [cpp.obj] Error 2

$

If you mean using the specifier 'class ...' in main then the word class
is redundant in this context, i.e. you can remove it and it will make no
difference. It's like declaring a 'long int' - the int is redundant:

$ type cpp.cpp
#include <iostream>
using std::cout;

class foo{
    public:
        foo(){cout << "foo::foo()\n"; }
        ~foo(){cout << "foo::~foo()\n"; }
        void bar(){cout << "foo::bar()\n";}
};
int main(){
    class foo* f = new foo;
    f->bar();
    delete f;
    return 0;
}

$ make
cl cpp.cpp /EHs /Zc:forScope /Wall /W4 /WL /wd4820 /wd4619 /wd4217
/wd4710 /wd4668 /c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for
80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

cpp.cpp
link cpp.obj /OUT:cpp.exe /nologo

$ cpp
foo::foo()
foo::bar()
foo::~foo()

$

--
PJH

"Consistently separating words by spaces became a general custom about
the tenth century A.D., and lasted until about 1957, when FORTRAN
abandoned the practice." -- Sun FORTRAN Reference Manual 





Alderley plc, Arnolds Field Estate, The Downs, Wickwar, Gloucestershire, GL12 
8JD, UK
Tel: +44(0)1454 294556 Fax: +44 (0)1454 299272

Website : www.alderley.com  Sales : [EMAIL PROTECTED] Service : [EMAIL 
PROTECTED]

This email and its contents are confidential and are solely for the use of the 
intended recipient. If you are not the original recipient you have received it 
in error and any use, dissemination, forwarding, printing or copying of this 
email is strictly prohibited. Should you receive this email in error please 
immediately notify [EMAIL PROTECTED]

This email has been scanned for viruses, however you should always scan emails 
with your own systems prior to opening.









------------------------ Yahoo! Groups Sponsor --------------------~--> 
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/EbFolB/TM
--------------------------------------------------------------------~-> 

To unsubscribe : [EMAIL PROTECTED]

 
Yahoo! Groups Links

<*> To reply to this message, go to:
    
http://groups.yahoo.com/group/Programmers-Town/post?act=reply&messageNum=4969
    Please do not reply to this message via email. More information here:
    http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> To visit your group on the web, go to:  
    http://groups.yahoo.com/group/Programmers-Town/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to