荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: tang (独孤九剑〖玄铁重剑〗), 信区: Program
标  题: [转载]  MSVC Digest - 12 Jan 1999 to 13 Jan 1999 (#1999-13)
发信站: BBS 荔园晨风站 (Thu Jan 14 22:36:14 1999), 站内信件

【 以下文字转载自 tang 的信箱 】
【 原文由 Automatic 所发表 】
There are 21 messages totalling 962 lines in this issue.

Topics of the day:

  1. Visual Database Tools
  2. How to get a file's icon? (2)
  3. My Membership ?? (3)
  4. Query on RUNTIME_CLASS() !! (4)
  5. Control Panel problem! (2)
  6. Help On CTypedPtrList !! (3)
  7. <No subject given> (2)
  8. Not a problem - just a query... (4)

--------------------------------------------------------------------------
The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
international's LISTSERV(R) software.  For subscription/signoff info
and archives, see http://peach.ease.lsoft.com/archives/msvc.html .

----------------------------------------------------------------------

Date:    Wed, 13 Jan 1999 08:14:42 +0100
From:    Frantisek Tripsky <frantisek.tripsky@TELECOM.CZ>
Subject: Visual Database Tools

Hi everybody,

 I need description of functions in dll-files Visual Database Tools . =
Does anybody know  where I could find this descriptions , please send me =
message=20

Thanks,
   Fero Tripsky

mailto: frantisek.tripsky@telecom.cz

------------------------------

Date:    Wed, 13 Jan 1999 09:15:25 +0100
From:    =?iso-8859-1?Q?Anders_W=E5hlin?= <wahlin@ERV.ERICSSON.SE>
Subject: How to get a file's icon?

How can I get an icon of a file? For example: .doc, .xls, .txt etc.

I know that I can check the registry for the "default icon" but this doesn't
always give me a correct value.
Does anyone know of a sample or anything that does this?

Thanks
/Anders W

------------------------------

Date:    Wed, 13 Jan 1999 10:08:00 +0100
From:    Mats M錸hav <mats@MOONSEA.COM>
Subject: Re: How to get a file's icon?

Hi Anders_W=E5hlin,

  Have a look at SHGetFileInfo();

Best regards,
Mats  mailto:mats@moonsea.com

onsdag, den 13 januari 1999, Anders_W=E5hlin wrote:
A> How can I get an icon of a file? For example: .doc, .xls, .txt etc.

A> I know that I can check the registry for the "default icon" but this d=
oesn't
A> always give me a correct value.
A> Does anyone know of a sample or anything that does this?

A> Thanks
A> /Anders W

A> ----------------------------------------------------------------------=
----
A> The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
A> international's LISTSERV(R) software.  For subscription/signoff info
A> and archives, see http://peach.ease.lsoft.com/archives/msvc.html .

------------------------------

Date:    Wed, 13 Jan 1999 17:23:45 +0530
From:    "Kameswara Rao M." <fd95522@BITS-PILANI.AC.IN>
Subject: My Membership ??

Dear MSVC host,

I, Kameswara Rao M. enrolled myself for MSVC 4 months back. Am still
receiving other members mails but failed to send mine yesterday. Please
check this & authorise my membership again.

My Details :

Name : Kameswara Rao M.
E-mail : fd95522@bits-pilani.ac.in

Sorry for the trouble ..

Thanking you sir,

Kameswara Rao M.

---------------------------------------------------------------------------

------------------------------

Date:    Wed, 13 Jan 1999 13:04:20 +0100
From:    Agata Wasilewska - Kopania <agata@MATRIX.PL>
Subject: Re: Query on RUNTIME_CLASS() !!

Sorry, I forgot: did you use DECLARE_SERIAL()  ?

Agata

> -----Original Message-----
> From: Kameswara Rao M.
> Sent: Tuesday, January 12, 1999 8:53 PM
> To:   MSVC@PEACH.EASE.LSOFT.COM
> Subject:      Query on RUNTIME_CLASS() !!
>
> Hai ...,
>
> It would be the greatest help a man can ever do if u solve my prob.
>
> ---> I derived  "CEquipment" from "CObject" & using CObList to store
> it. The code
>
>         CEquipment* ptemp = (CEquipment *) pDoc->EquipmentList(pos);
>         ASSERT(ptemp->IsKindOf(RUNTIME_CLASS(CEquipment));
>
>         is causing a Assertion failure.
>
>         *) I used IMPLEMENT_SERIAL() for "CEquipment"
>         *) I declared CObList EquipmentList;
>         ?) should "CObList" object also should be said IMPLEMENT_SERIAL().
>
>
> please help me.
>
> Thanx to everyone who spend their time knowing my problem ..
>
> Yours friendly,
>
> Kameswara Rao M.
>
> -------------------------------------------------------
>
>
> --------------------------------------------------------------------------
> The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
> international's LISTSERV(R) software.  For subscription/signoff info
> and archives, see http://peach.ease.lsoft.com/archives/msvc.html .

------------------------------

Date:    Wed, 13 Jan 1999 12:06:50 -0000
From:    Geoffrey Howie <gh197@DOC.IC.AC.UK>
Subject: Re: My Membership ??

Kameswara,

The way this list seems to work is that you don't get sent back your own
mailings - I cant see mine either, but i do get replies to them. I saw your
message "Query on runtime class", so it has been posted.
Hope this helps,

Gef Howie (List user, not host!)

-----Original Message-----
From: Microsoft Visual C++ programmers list
[mailto:MSVC@PEACH.EASE.LSOFT.COM]On Behalf Of Kameswara Rao M.
Sent: Wednesday, January 13, 1999 11:54 AM
To: MSVC@PEACH.EASE.LSOFT.COM
Subject: My Membership ??


Dear MSVC host,

I, Kameswara Rao M. enrolled myself for MSVC 4 months back. Am still
receiving other members mails but failed to send mine yesterday. Please
check this & authorise my membership again.

------------------------------

Date:    Wed, 13 Jan 1999 17:49:30 +0530
From:    "Kameswara Rao M." <fd95522@BITS-PILANI.AC.IN>
Subject: Re: Query on RUNTIME_CLASS() !!

Hello ...,

Though a beginner I didnot make such a silly mistake.

Thanx & think of something wild !

Bye.
--------------------------------------

On Wed, 13 Jan 1999, Agata Wasilewska - Kopania wrote:

> Sorry, I forgot: did you use DECLARE_SERIAL()  ?
>
> Agata
>
> > -----Original Message-----
> > From: Kameswara Rao M.
> > Sent: Tuesday, January 12, 1999 8:53 PM
> > To:   MSVC@PEACH.EASE.LSOFT.COM
> > Subject:      Query on RUNTIME_CLASS() !!
> >
> > Hai ...,
> >
> > It would be the greatest help a man can ever do if u solve my prob.
> >
> > ---> I derived  "CEquipment" from "CObject" & using CObList to store
> > it. The code
> >
> >         CEquipment* ptemp = (CEquipment *) pDoc->EquipmentList(pos);
> >         ASSERT(ptemp->IsKindOf(RUNTIME_CLASS(CEquipment));
> >
> >         is causing a Assertion failure.
> >
> >         *) I used IMPLEMENT_SERIAL() for "CEquipment"
> >         *) I declared CObList EquipmentList;
> >         ?) should "CObList" object also should be said IMPLEMENT_SERIAL().
> >
> >
> > please help me.
> >
> > Thanx to everyone who spend their time knowing my problem ..
> >
> > Yours friendly,
> >
> > Kameswara Rao M.
> >
> > -------------------------------------------------------
> >
> >
> > --------------------------------------------------------------------------
> > The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
> > international's LISTSERV(R) software.  For subscription/signoff info
> > and archives, see http://peach.ease.lsoft.com/archives/msvc.html .
>
> --------------------------------------------------------------------------
> The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
> international's LISTSERV(R) software.  For subscription/signoff info
> and archives, see http://peach.ease.lsoft.com/archives/msvc.html .
>

------------------------------

Date:    Wed, 13 Jan 1999 12:21:32 -0000
From:    Shashi Kant <ShashiK@PEREGRINE.IE>
Subject: Re: My Membership ??

Hi! If you read the list welcome message you get when you registered -
you would have noticed that your postings can be toggled on/off
by sending a command to the Listserv -Listserv is a software not a person!

It is always a good idea to archive the List welcome messages(for any
list you enroll to) - you may need it to unsubscribe or change your
settings etc.
To get a copy of your own postings send the command

SET MSVC REPRO

in the body of mail message to
<listserv@peach.ease.lsoft.com>

If you need more info send HELP to the same address or browse
to the URL the mailer appends to every posting(see signature)

HTH
Shashi


-----Original Message-----
From: Microsoft Visual C++ programmers list
[mailto:MSVC@PEACH.EASE.LSOFT.COM]On Behalf Of Geoffrey Howie
Sent: Wednesday, January 13, 1999 12:07 PM
To: MSVC@PEACH.EASE.LSOFT.COM
Subject: Re: My Membership ??


Kameswara,

The way this list seems to work is that you don't get sent back your own
mailings - I cant see mine either, but i do get replies to them. I saw your
message "Query on runtime class", so it has been posted.
Hope this helps,

Gef Howie (List user, not host!)

------------------------------

Date:    Wed, 13 Jan 1999 12:57:56 +0100
From:    Agata Wasilewska - Kopania <agata@MATRIX.PL>
Subject: Re: Query on RUNTIME_CLASS() !!

I think you should use DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE for your
CEquipment class.

Agata
> -----Original Message-----
> From: Kameswara Rao M.
> Sent: Tuesday, January 12, 1999 8:53 PM
> To:   MSVC@PEACH.EASE.LSOFT.COM
> Subject:      Query on RUNTIME_CLASS() !!
>
> Hai ...,
>
> It would be the greatest help a man can ever do if u solve my prob.
>
> ---> I derived  "CEquipment" from "CObject" & using CObList to store
> it. The code
>
>         CEquipment* ptemp = (CEquipment *) pDoc->EquipmentList(pos);
>         ASSERT(ptemp->IsKindOf(RUNTIME_CLASS(CEquipment));
>
>         is causing a Assertion failure.
>
>         *) I used IMPLEMENT_SERIAL() for "CEquipment"
>         *) I declared CObList EquipmentList;
>         ?) should "CObList" object also should be said IMPLEMENT_SERIAL().
>
>
> please help me.
>
> Thanx to everyone who spend their time knowing my problem ..
>
> Yours friendly,
>
> Kameswara Rao M.
>
> -------------------------------------------------------
>
>
> --------------------------------------------------------------------------
> The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
> international's LISTSERV(R) software.  For subscription/signoff info
> and archives, see http://peach.ease.lsoft.com/archives/msvc.html .

------------------------------

Date:    Wed, 13 Jan 1999 20:08:58 +0530
From:    "Kameswara Rao M." <fd95522@BITS-PILANI.AC.IN>
Subject: Re: Query on RUNTIME_CLASS() !!

Thankyou Agata.

But even then it is not working. The error is

        " Access violation ". Because both DECLARE_SERIAL  &
DECLARE_DYNCREATE can call CObject::IsKindOf() to determine RTTI and that
is what exactly is causing an "Failure" here !.

please keep suggesting .....

Thanx.

---------------------------------------------

On Wed, 13 Jan 1999, Agata Wasilewska - Kopania wrote:

> I think you should use DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE for your
> CEquipment class.
>
----------------------------------------------
> > ---> I derived  "CEquipment" from "CObject" & using CObList to store
> > it. The code
> >
> >         CEquipment* ptemp = (CEquipment *) pDoc->EquipmentList(pos);
> >         ASSERT(ptemp->IsKindOf(RUNTIME_CLASS(CEquipment));
> >
> >         is causing a Assertion failure.
> >
> >         *) I used IMPLEMENT_SERIAL() for "CEquipment"
> >         *) I declared CObList EquipmentList;
> >         ?) should "CObList" object also should be said IMPLEMENT_SERIAL().
> >
> >
> > please help me.
> >
> > Thanx to everyone who spend their time knowing my problem ..
> >
> > Yours friendly,
> >
> > Kameswara Rao M.
> >
> > -------------------------------------------------------
> >
> >
> > --------------------------------------------------------------------------
> > The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
> > international's LISTSERV(R) software.  For subscription/signoff info
> > and archives, see http://peach.ease.lsoft.com/archives/msvc.html .
>
> --------------------------------------------------------------------------
> The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
> international's LISTSERV(R) software.  For subscription/signoff info
> and archives, see http://peach.ease.lsoft.com/archives/msvc.html .
>

------------------------------

Date:    Wed, 13 Jan 1999 16:05:57 +0100
From:    =?iso-8859-1?Q?Anders_W=E5hlin?= <wahlin@ERV.ERICSSON.SE>
Subject: Control Panel problem!

Hello.

I must be missing something basic here!

I have developed a ControlPanel, which works fine on the "developer
computer". But when I copy the .cpl file to another computer
(C:\WINNT\System32) it doesn't apper in the Control Panel Folder. What am I
missing?

/Anders W

------------------------------

Date:    Wed, 13 Jan 1999 07:41:39 -0800
From:    Ted Neward <ted@CWNET.COM>
Subject: Re: Control Panel problem!

Anders--

Debugging .CPLs is something of a fine art, and one which I don't pretend=
 to
be a guru at. However, one problem I can think of off the top of my head =
is
to make sure that the .CPL has all of its required supporting DLLs (MFC
DLLs, make sure the two machines are on the same Service Pack, and if not=
,
which DLLs are different, blah, blah, blah). Under Windows, if a DLL fail=
s
an import of another DLL, it will silently fail with no real warning.

Ted Neward
Consultant
C++/Java/CORBA/COM/EJB/Web spoken here
-----Original Message-----
From: Anders W=E5hlin <wahlin@ERV.ERICSSON.SE>
To: MSVC@PEACH.EASE.LSOFT.COM <MSVC@PEACH.EASE.LSOFT.COM>
Date: Wednesday, January 13, 1999 7:10 AM
Subject: Control Panel problem!


>Hello.
>
>I must be missing something basic here!
>
>I have developed a ControlPanel, which works fine on the "developer
>computer". But when I copy the .cpl file to another computer
>(C:\WINNT\System32) it doesn't apper in the Control Panel Folder. What a=
m I
>missing?
>
>/Anders W
>
>------------------------------------------------------------------------=
--
>The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
>international's LISTSERV(R) software.  For subscription/signoff info
>and archives, see http://peach.ease.lsoft.com/archives/msvc.html .
>

------------------------------

Date:    Wed, 13 Jan 1999 21:32:27 +0530
From:    "Kameswara Rao M." <fd95522@BITS-PILANI.AC.IN>
Subject: Help On CTypedPtrList !!

I have a problem using CTypedPtrList. My declaration

        CTypedPtrList<CObList, CEquipment*> CMyList;

        CEquipment is an CObject derived & IMPLEMENT_DYNCREATE() is used.

        I get a compile time error pointing a wrong in the declaration of
CTypePtrList<>.

please help ...

Thanx to everyone who spent their time reading my problem .....
-------------------------------------------------------------

------------------------------

Date:    Wed, 13 Jan 1999 16:09:04 -0000
From:    Paul Morris-Munro <P.Morris-Munro@YMI.CO.UK>
Subject: Re: Help On CTypedPtrList !!

Have written an overload operator<>  for CEquipment* ?



>----------
>From:  Kameswara Rao M.[SMTP:fd95522@BITS-PILANI.AC.IN]
>Sent:  Wednesday, January 13, 1999 4:02 PM
>To:    MSVC@PEACH.EASE.LSOFT.COM
>Subject:       Help On CTypedPtrList !!
>
>I have a problem using CTypedPtrList. My declaration
>
>        CTypedPtrList<CObList, CEquipment*> CMyList;
>
>        CEquipment is an CObject derived & IMPLEMENT_DYNCREATE() is
>used.
>
>        I get a compile time error pointing a wrong in the declaration
>of
>CTypePtrList<>.
>
>please help ...
>
>Thanx to everyone who spent their time reading my problem .....
>-------------------------------------------------------------
>
>------------------------------------------------------------------------
>--
>The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
>international's LISTSERV(R) software.  For subscription/signoff info
>and archives, see http://peach.ease.lsoft.com/archives/msvc.html .
>

------------------------------

Date:    Wed, 13 Jan 1999 22:03:16 +0530
From:    fd95498@IPC.BITS-PILANI.AC.IN
Subject: <No subject given>

MSVC SUBSCRIBE

------------------------------

Date:    Wed, 13 Jan 1999 12:26:31 -0500
From:    "Swirski, Zbyszek" <Zbyszek.Swirski@AEXP.COM>
Subject: Re: Help On CTypedPtrList !!

Why aren't you using
        CTypedPtrList<CPtrList, CEquipment*> CMyList;
You want to keep pointers not objects aren't you ?
Zbyszek

-----Original Message-----
From: Kameswara Rao M. [mailto:fd95522@BITS-PILANI.AC.IN]
Sent: Wednesday, January 13, 1999 4:02 PM
To: MSVC@PEACH.EASE.LSOFT.COM
Subject: Help On CTypedPtrList !!


I have a problem using CTypedPtrList. My declaration

        CTypedPtrList<CObList, CEquipment*> CMyList;

        CEquipment is an CObject derived & IMPLEMENT_DYNCREATE() is
used.

        I get a compile time error pointing a wrong in the declaration
of
CTypePtrList<>.

please help ...

Thanx to everyone who spent their time reading my problem .....
-------------------------------------------------------------

------------------------------------------------------------------------
--
The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
international's LISTSERV(R) software.  For subscription/signoff info
and archives, see http://peach.ease.lsoft.com/archives/msvc.html .

------------------------------

Date:    Wed, 13 Jan 1999 12:35:18 -0500
From:    Richard Pickett <rpickett@NORTELNETWORKS.COM>
Subject: <No subject given>

Hello,

        You should send your subscription request to
LISTSERV@PEACH.EASE.LSOFT.COM <mailto:LISTSERV@PEACH.EASE.LSOFT.COM> .  The
message bellow was posted to all the subscribers of the list and did not
subscribe you to the list.

Richard W. Pickett Jr.
Windows NT Server System Engineer
rpickett@NortelNetworks.com <mailto:rpickett@NortelNetworks.com>

        -----Original Message-----
        From:   fd95498@IPC.BITS-PILANI.AC.IN
[SMTP:fd95498@IPC.BITS-PILANI.AC.IN]
        Sent:   Wednesday, January 13, 1999 10:33 AM
        To:     MSVC@PEACH.EASE.LSOFT.COM
        Subject:

        MSVC SUBSCRIBE


--------------------------------------------------------------------------
        The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
        international's LISTSERV(R) software.  For subscription/signoff info
        and archives, see http://peach.ease.lsoft.com/archives/msvc.html .

------------------------------

Date:    Wed, 13 Jan 1999 17:48:10 -0000
From:    Cliff Rowley <CRowley@COMTEST.CO.UK>
Subject: Not a problem - just a query...

This is not a problem, I'm just enquiring here...
=A0
Take the following example:
=A0
class CFoobar
{
public:
=A0=A0=A0 CFoobar();
=A0=A0=A0 ~CFoobar();
=A0=A0=A0 SetText(LPCTSTR lpszText) { m_strText =3D lpszText; }
=A0=A0=A0 LPCTSTR GetText() { return m_strText; }
protected:
=A0=A0=A0 CString m_strText;
};
=A0
You'll notice that I have supplied no return value for SetText.=A0 By
rights this should not compile, but should say something along the =
lines
of "Error:=A0 SetText must return a value".=A0 But it doesnt.=A0 The =
program
compiles, and I get a warning like "Warning:=A0 SetText looks like a =
CTor
but does not have the same name as the class".
=A0
Is this legal C++?=A0 I dont think it is...
=A0
Any comments?

------------------------------

Date:    Wed, 13 Jan 1999 13:47:21 -0500
From:    Timothy Dixon <tdixon@PHDINC.COM>
Subject: Re: Not a problem - just a query...

I think it's assuming the SetText returns void, since you haven't
sepecified a return value for SetText.  In which case it wouldn't need a
return value.  I'm not entirely certain, because I always specify my return
type even if it is void, simply to avoid this kind of confusion.

Um.. Not sure what's meant by the error message.  Maybe a namesapce
problem?

Tim Dixon, Software Engineer
PHD, Inc. http://www.phdinc.com






CRowley@COMTEST.CO.UK on 01/13/99 12:48:10 PM

Please respond to MSVC@PEACH.EASE.LSOFT.COM

To:   MSVC@PEACH.EASE.LSOFT.COM
cc:    (bcc: Tim Dixon/PHD)
Subject:  Not a problem - just a query...




This is not a problem, I'm just enquiring here...
Take the following example:
class CFoobar
{
public:
??? CFoobar();
??? ~CFoobar();
??? SetText(LPCTSTR lpszText) { m_strText = lpszText; }
??? LPCTSTR GetText() { return m_strText; }
protected:
??? CString m_strText;
};
You'll notice that I have supplied no return value for SetText.? By
rights this should not compile, but should say something along the lines
of "Error:? SetText must return a value".? But it doesnt.? The program
compiles, and I get a warning like "Warning:? SetText looks like a CTor
but does not have the same name as the class".
Is this legal C++?? I dont think it is...
Any comments?
--------------------------------------------------------------------------
The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
international's LISTSERV(R) software.  For subscription/signoff info
and archives, see http://peach.ease.lsoft.com/archives/msvc.html .

------------------------------

Date:    Wed, 13 Jan 1999 13:54:57 -0500
From:    Richard Pickett <rpickett@NORTELNETWORKS.COM>
Subject: Re: Not a problem - just a query...

Hello Cliff,

        First let me say to all on the list, sorry about my STUPID reply to
someone's request for subscription.  I thought for sure I had just =
specified
them in the reply, but evidently not.  Thanks for not escalating it =
into a
week of rants on wasted email and how long it took to download that =
HUGE
email and how your ISP is sending you a bill twice the normal size =
because
of email traffic. :-).

        Here's the syntax of a function definition in C++:

[decl-specifiers] declarator [ctor-initializer] fct-body

        I have placed the optional parameters in brackets.  As you can see
the decl-specifiers are not necessary.  The ctor-initilizer section is
strictly for constructors, it is where you would put the base class
initializations.  For some reason (and it escaping me as to why) your
compiler thinks the SetText method is a constructor or should be a
constructor, thus it is calling it a "ctor".  And it is throwing the =
warning
that the ctor doesn't have the same name as the class because all
constructors (ctors) have the same name as the class.

        Now about the return type.  The default return type (decl-specifier)
if no return type is specified is void.  Think about it  what =
parameters
does this function take:

DummyFunc( );

        It takes none (or void) because none were specified.  Same with the
return type.  If there is no return type specified then nothing (void) =
can
be returned.  The following function declaration is the same as the one
above, but it is "safer" because nothing is left to default.

void DummyFunc( void );

        A lot of lint programs will flag the first declaration of DummyFunc
because although void is implied it is not specified.

Richard W. Pickett Jr.
Windows NT Server System Engineer
rpickett@NortelNetworks.com <mailto:rpickett@NortelNetworks.com>=20

        -----Original Message-----
        From:   Cliff Rowley [SMTP:CRowley@COMTEST.CO.UK]
        Sent:   Wednesday, January 13, 1999 11:48 AM
        To:     MSVC@PEACH.EASE.LSOFT.COM
        Subject:        Not a problem - just a query...

        This is not a problem, I'm just enquiring here...
        =A0
        Take the following example:
        =A0
        class CFoobar
        {
        public:
        =A0=A0=A0 CFoobar();
        =A0=A0=A0 ~CFoobar();
        =A0=A0=A0 SetText(LPCTSTR lpszText) { m_strText =3D lpszText; }
        =A0=A0=A0 LPCTSTR GetText() { return m_strText; }
        protected:
        =A0=A0=A0 CString m_strText;
        };
        =A0
        You'll notice that I have supplied no return value for SetText.=A0 By
        rights this should not compile, but should say something along the
lines
        of "Error:=A0 SetText must return a value".=A0 But it doesnt.=A0 The
program
        compiles, and I get a warning like "Warning:=A0 SetText looks like a
CTor
        but does not have the same name as the class".
        =A0
        Is this legal C++?=A0 I dont think it is...
        =A0
        Any comments?

=09
------------------------------------------------------------------------=
--
        The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
        international's LISTSERV(R) software.  For subscription/signoff info
        and archives, see http://peach.ease.lsoft.com/archives/msvc.html .

------------------------------

Date:    Wed, 13 Jan 1999 13:10:22 -0800
From:    Dave Thompson <thmpsn@PRIMENET.COM>
Subject: Re: Not a problem - just a query...

The reason for the warning about the fact that it looks like a constructo=
r
is because if you made a slight miss-spelling of your constructor so that=
 it
did not match the class name, you would be debugging once you discovered =
the
constructor was not working. This is a very good warning since for style
reasons the constructor is usually made without a return type and your vo=
ids
would usually be declared as returning void.  This can save a lot of
headaches.

> -----Original Message-----
> From: Microsoft Visual C++ programmers list
> [mailto:MSVC@PEACH.EASE.LSOFT.COM]On Behalf Of Richard Pickett
> Sent: Wednesday, January 13, 1999 10:55 AM
> To: MSVC@PEACH.EASE.LSOFT.COM
> Subject: Re: Not a problem - just a query...
>
>
> Hello Cliff,
>
>         First let me say to all on the list, sorry about my
> STUPID reply to
> someone's request for subscription.  I thought for sure I had
> just specified
> them in the reply, but evidently not.  Thanks for not escalating it int=
o a
> week of rants on wasted email and how long it took to download that HUG=
E
> email and how your ISP is sending you a bill twice the normal size beca=
use
> of email traffic. :-).
>
>         Here's the syntax of a function definition in C++:
>
> [decl-specifiers] declarator [ctor-initializer] fct-body
>
>         I have placed the optional parameters in brackets.  As you can =
see
> the decl-specifiers are not necessary.  The ctor-initilizer section is
> strictly for constructors, it is where you would put the base class
> initializations.  For some reason (and it escaping me as to why) your
> compiler thinks the SetText method is a constructor or should be a
> constructor, thus it is calling it a "ctor".  And it is throwing
> the warning
> that the ctor doesn't have the same name as the class because all
> constructors (ctors) have the same name as the class.
>
>         Now about the return type.  The default return type
> (decl-specifier)
> if no return type is specified is void.  Think about it  what parameter=
s
> does this function take:
>
> DummyFunc( );
>
>         It takes none (or void) because none were specified.
> Same with the
> return type.  If there is no return type specified then nothing (void) =
can
> be returned.  The following function declaration is the same as the one
> above, but it is "safer" because nothing is left to default.
>
> void DummyFunc( void );
>
>         A lot of lint programs will flag the first declaration of
> DummyFunc
> because although void is implied it is not specified.
>
> Richard W. Pickett Jr.
> Windows NT Server System Engineer
> rpickett@NortelNetworks.com <mailto:rpickett@NortelNetworks.com>
>
>         -----Original Message-----
>         From:   Cliff Rowley [SMTP:CRowley@COMTEST.CO.UK]
>         Sent:   Wednesday, January 13, 1999 11:48 AM
>         To:     MSVC@PEACH.EASE.LSOFT.COM
>         Subject:        Not a problem - just a query...
>
>         This is not a problem, I'm just enquiring here...
>         =A0
>         Take the following example:
>         =A0
>         class CFoobar
>         {
>         public:
>         =A0=A0=A0 CFoobar();
>         =A0=A0=A0 ~CFoobar();
>         =A0=A0=A0 SetText(LPCTSTR lpszText) { m_strText =3D lpszText; }
>         =A0=A0=A0 LPCTSTR GetText() { return m_strText; }
>         protected:
>         =A0=A0=A0 CString m_strText;
>         };
>         =A0
>         You'll notice that I have supplied no return value for
> SetText.=A0 By
>         rights this should not compile, but should say something along =
the
> lines
>         of "Error:=A0 SetText must return a value".=A0 But it doesnt.=A0=
 The
> program
>         compiles, and I get a warning like "Warning:=A0 SetText looks l=
ike a
> CTor
>         but does not have the same name as the class".
>         =A0
>         Is this legal C++?=A0 I dont think it is...
>         =A0
>         Any comments?
>
>
> -----------------------------------------------------------------------=
---
>         The MSVC list is hosted on a Windows NT(TM) machine running L-S=
oft
>         international's LISTSERV(R) software.  For
> subscription/signoff info
>         and archives, see http://peach.ease.lsoft.com/archives/msvc.htm=
l .
>
> -----------------------------------------------------------------------=
---
> The MSVC list is hosted on a Windows NT(TM) machine running L-Soft
> international's LISTSERV(R) software.  For subscription/signoff info
> and archives, see http://peach.ease.lsoft.com/archives/msvc.html .
>

------------------------------

End of MSVC Digest - 12 Jan 1999 to 13 Jan 1999 (#1999-13)
**********************************************************
--
※ 转载:.BBS 荔园晨风站 bbs.szu.edu.cn.[FROM: 192.168.0.4]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店