class + class-name ?

This question may look silly but anyhow I have to know it!
 In a code there was a line like :

 class Doc;
.....

what does this do when you only use keyword "clas"  and then a calss-name ?

Thanks in advance,


0
10/22/2004 8:29:28 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
489 Views

Similar Articles

[PageSpeed] 33

    It is a forward declaration. See


http://msdn.microsoft.com/library/en-us/vclang/html/_pluslang_elaborated_type_specifiers.asp

-- 
Cheers
Check Abdoul [VC++ MVP]
-----------------------------------

"JSmith" <jsmithmitra@yahoo.com> wrote in message
news:evc$zXHuEHA.220@TK2MSFTNGP15.phx.gbl...
> This question may look silly but anyhow I have to know it!
>  In a code there was a line like :
>
>  class Doc;
> ....
>
> what does this do when you only use keyword "clas"  and then a calss-name
?
>
> Thanks in advance,
>
>


0
CheckAbdoul
10/22/2004 8:33:22 PM
If this is in a .h File then it is a "FORWARD" declaration of that 
particular class.
Stops the compiler bitching about an undefined class when you need to this 
..h file somewhere int your project but don't make any reference to that 
class in that particular cpp file.

M

"JSmith" <jsmithmitra@yahoo.com> wrote in message 
news:evc$zXHuEHA.220@TK2MSFTNGP15.phx.gbl...
> This question may look silly but anyhow I have to know it!
> In a code there was a line like :
>
> class Doc;
> ....
>
> what does this do when you only use keyword "clas"  and then a calss-name 
> ?
>
> Thanks in advance,
>
> 


0
10/22/2004 8:41:49 PM
JSmith wrote:
> In a code there was a line like :
>
> class Doc;
>
> what does this do when you only use keyword "clas"  and then a
> calss-name ?

It lets the compiler know that there's a class named Doc declared somewhere. 
The reason this is useful is that the compiler will accept Doc* and Doc& 
even though it does not know what the Doc class actually looks like.

E.g.
    class CJalla;
    void f(CJalla *Jalla);
will compile even though the compiler hasn't seen the prototype for CJalla.


-- 

Sigurd
http://utvikling.com 


0
sigurds (118)
10/22/2004 9:02:08 PM
In addition to other replies, there is another very good reason to do this:

Consider the following:

class CSomeClass;

class CYourClass
{
 ....
    void somemethod(CSomeClass*ptr);
 .....
};

Now since you have forward declared someotherclass, any changes you make to
someotherclass do not require a recompile of CYourClass. It becomes a big
deal if you have large projects where changes made to one class may result
in compilation of various files. Forward declaration is typically a very
good thing to do.

--
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com


"JSmith" <jsmithmitra@yahoo.com> wrote in message
news:evc$zXHuEHA.220@TK2MSFTNGP15.phx.gbl...
> This question may look silly but anyhow I have to know it!
>  In a code there was a line like :
>
>  class Doc;
> ....
>
> what does this do when you only use keyword "clas"  and then a calss-name
?
>
> Thanks in advance,
>
>


0
ajaykalra (6842)
10/23/2004 3:31:44 AM
Reply:

Similar Artilces:

two accounts, sender's name appeared wrong in outbox
I set up two account in outlook 2002(first use, before I use outlook express). Every thing goes well except sender's name appear wrong in outbox. For example, I set up two accounts A and B. Accordingly, sender name is A_sender and B-sender.A account is defult. sender name is A_sender when I send email by B accout. I don't know how to fix it. Any advice. "David_Ye" <David_Ye@discussions.microsoft.com> wrote in message news:744C1140-9C32-49EB-ADF8-6CA46E34091C@microsoft.com... >I set up two account in outlook 2002(first use, before I use outlook > ex...

Setting the "Class Cursor"
This is a multi-part message in MIME format. ------=_NextPart_000_0012_01C3FF6B.C7507BF0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable The documentation for SetCursor() reads, in part: If your application must set the cursor while it is in a window, make = sure the class cursor for the specified window's class is set to NULL. = If the class cursor is not NULL, the system restores the class cursor = each time the mouse is moved.=20 How does one set the "class cursor"? Jason ------=_NextPart_000_0012_01C3FF6B.C7507BF0 C...

Default Labor class in BP 2.5 project time entry
I have setup the business portal and configured a couple of project users to access the project time entry screen. I would like to customize this screen by making the labor class invisible, however it is not populated by default on the portal web page (although it is on backoffice version). The clients are XP with IE 6 SP1, I searched the CustomerSource KB and entry 848372 looked promising, but on these machines there is no Java Sun setting (or MS JVM section although I see this on other machines). Has anyone else ran into this and figured out a workaround? Thanks, Dave I think I answered m...

Named Ranges in Seperate Workbook
Hi, I have a Summary workbook that has multiple charts that are copied/linked to different source workbooks. The Source workbook chart is created using dyamic named ranges (e.g. source_xvalues). I am getting odd behavior and don't understand how or what order excel looks at different workbooks. If both the Summary and Source workbooks are open, life is grand. In some cases, if I close the Source, the series disappear from the Summary chart. In other cases, the series don't disappear. Any suggestions as to how to handle this problem? Regards Tim Tim - I did a little experiment...

MFC class wizard and IDISPATCH
Hello In ATL projects wizard give us a chance to add class with Idispatch(Dual). In MFC add class wizard, there is an option for Automation but this cause to add dispintarface. Also activex control projects add interfaces with dispintarface which means user can only use late-binding. Mayeb this may performance problems. I am not sure? Is there a special reason to doesn't have an option for dual interface in MFC project wizards..? If we want to use dual interfaces in ou project, what must we do? Just manual edit? Thanks.. I think that if you want a more "COM-centric" ap...

Seperate file extension from file name
In my code I have the user select a file to be copied. It then prompts the user for the new name of the file. The file is then saved as a string (e.g. "MyFileName.txt") I need to seperate the file name from the file's extension so I can have "MyFileName" and know that it's extension is ".txt" I think I can just use Left(myStringName, Len(myStringName) - 4) However: a) am i write in assuming that all file extensions are 3 charactors plus a period? b) what's the easiest way to check if the user provide file name includes a valid extension so i know...

last name, first name strings
:confused: Hi there, I am a newbie and am having some trouble with seperating data in Excel. Here is my issue: I have a table of employee names are in one column alone, but all in a different format: first name -space- last name last name, first name last name -space- first name What I am needing to do is get all the names to be in the same order and seperated into two columns as: Last Name column First Name column How do I take those combined name formats that are in one column and seperate them into seperate columns in the correct order? Thanks, Christina :confused: -- data_div...

#name? errors on spreadsheet
I'm trying to create a spreadsheet to automatically track Word documents' date. I'm copying the date from the title page and pasting into the Excel cell using Paste Special and creating a link to the text. It works when I set it up, but when I close the spreadsheet and then reopen it the linking process shows the #NAME? error. How can I correct this? -- John Gentile, MS M(ASCP) Phone: (401) 273-7100 ext 2046 Fax: (401) 457-3069 e-mail: john.gentile@med.va.gov Laboratory Information Manager VAMC Providence Hello, Providence. I go to Wilkes Barre. :) Does the title have...

how do I use MFC data member from a concrete C++ class from a COM interface
Hello I have created a new thread because the subject is somewhat different. I use a C# asp.net webbapplication which call different COM object using the defined COM interface for each concrete C++ class. So at the bottom I have a OpenDS method located in the concrete C++ class CHandle_DS. This method is also define at the IHandle_DS COM interface. Here is the sequence for my new design for the new concrete C++ object 1. I create a concrete C++ class from C# asp.net like this CHande_DS handle_ds = new Handle_DS(); This works perfect. 2. I call OpenDS like this handle_ds.OpenDS(); ...

Classes gone from class list
Why might some of my classes dissappear from the Class View in VS2005? I am also getting error 2079 for some classes that were fine half an hour ago and still exist in the Class View window. The header and cpp files for the missing and broken classes are included in my project. Everything was fine until about half an hour ago - I added 1 pure virtual operation to a base class and a concrete method to 9 subclasses, (I think this is irrelevant!) and half of the classes are now missing and I can't use the others. The method was called SortList() and calls a list sort operation specifi...

Change the Range of a Name
Is There a possibility, to change the Range of a name-dependent of the value of a Variable(perhaps Startrow rsp. Endrow)-with with a VBA-statement? Thank you for a good hint! dim Startrow as long dim endrow as long with activesheet .range(.cells(startrow,"B"),.cells(endrow,"c")).name = "myName" end with if myName already exists, this'll reassign it. If it didn't exist, it'll get created. (Did I misunderstand the question?) "H�lzl Otto" wrote: > > Is There a possibility, to change the Range of a name-dependent of the value &g...

Using .NET XmlDocument Class, How to use a xpath expression on xml document which has a default namespace
for example, xml document is below, It has a default namespace "xmlns='qwer://test'". string xmlText = "<test xmlns='http://test'><clear/><clear/></test>"; I would like to select node list "clear" with XPath Expression. XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml( xmlText ); XmlNamespaceManager xsn = new XmlNamespaceManager( xmlDoc.NameTable ); xsn.AddNamespace( "", "http://test" ); string xPath = "//clear"; ...

name of web service address
"glenn nehh" <glenn nehh@discussions.microsoft.com> wrote in message news:4ECA33FA-757C-4372-8032-97B2F976E887@microsoft.com... > I shall name it... Bob. In all seriousness, huh? -- f.h. ...

class + class-name ?
This question may look silly but anyhow I have to know it! In a code there was a line like : class Doc; ..... what does this do when you only use keyword "clas" and then a calss-name ? Thanks in advance, It is a forward declaration. See http://msdn.microsoft.com/library/en-us/vclang/html/_pluslang_elaborated_type_specifiers.asp -- Cheers Check Abdoul [VC++ MVP] ----------------------------------- "JSmith" <jsmithmitra@yahoo.com> wrote in message news:evc$zXHuEHA.220@TK2MSFTNGP15.phx.gbl... > This question may look silly but anyhow I have to know i...

Nested class using MFC
Hello! I'm using a COM Dll and a COM client that I have copied from a book. This COM dll is using MFC and the COM client exe file is also using MFC. I have removed some code just to make it easier to figure out my problem. The code that I have removed does't affect the question in any way. In the code you have one interface called IVisual you have it below. struct IVisual : public IUnknown { STDMETHOD_(void, Display) () = 0; }; As you know in Interface IUnknown are there three pure virtual functiones named QueryInterface, AddRef and Release. The functions QueryInterface, AddRef...

Lookup in named range
Afternoon Im currently creating a lookup formula between two worksheets, and would find it easier to make my formula search within name ranges rather than cell references. Im having problems making this work though. My current formula reads. =INDEX('Communal Areas'!A2:H804,MATCH(E2,'Communal Areas'!D2:D804,0),7) The name range for A2:H804 is Communal, and the name range for D2:D804 is Street. When I enter these though my formula comes back in error. I assume then that I am entering them into the formula incorrectly. Does anyone know how this should be done? Thanks i...

Creating and Destroying a Window in CWinThread Derived Class
Hello, (Using VC++ 6.0) I am extremely frustrated with this and have burned many hours and still no solution. This should be simple. I have created a sample app that does the following: 1) Creates a CWinThread derived class from Class Wizard called SeperateThread. 2) Creates a modeless dialog box on thread initialization 3) Destroys it on ExitInstance() SeperateThread. Problem: ExitInstance() in cannot destroy the window I created just above on thread InitInstance(). Code Snippets: CTestThreaddingJunkDlg.h CSeperateThread ThreadA; declared in the base .h file In CTestThreaddingJun...

Extending the Process class
The System.Diagnostics namespace contains a Process class which defines a static method GetProcesses. GetProcesses returns an array of Process instances of all processes running running on the PC (or another PC). I wish to subclass Process to include an additional property. My problem is with the GetProcesses method. Since its return value is a Process[], I cannot just downcast a Process element to MyProcess to access the my property as well as the ones the Process already defines. Since the fetching of all processes occurs frequently, and the list can be long, I would prefer to...

Pivot Table with Define name
Hello: Is it possible to use define name in Pivot Table that the define name is link to another woeksheet? Thanks! You can use a named range in another workbook, if that workbook is open. Or, in step 1 of the pivot table wizard, select external data source, and connect to the other workbook. Alan Tang wrote: > Hello: > > Is it possible to use define name in Pivot Table that the define name is > link to another woeksheet? > > Thanks! -- Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html ...

How can I change a list of phone numbers into peoples names
I have a large list of phone number from my phone bill which I have copied into Excel and I would like to somehow lookup the number in my phone book which is also in Excel and show the persons name from the phone number. "John" <John@discussions.microsoft.com> ha scritto nel messaggio news:EB3EB5D6-BC8A-43F6-8CFE-61B3FF53F3C3@microsoft.com... >I have a large list of phone number from my phone bill which I have copied > into Excel and I would like to somehow lookup the number in my phone book > which is also in Excel and show the persons name from the phone number. ...

Thread Pool Class?
Can anyone recommend a good thread pool class? "Don Gurr" <dongurr@REMOVEshaw.ca> ha scritto nel messaggio news:2do6n.2339$RS6.61@newsfe15.iad... > Can anyone recommend a good thread pool class? Have you tried CThreadPool from ATL (I believe it can be used in MFC code as well)? http://msdn.microsoft.com/en-us/library/9tz6fz1e(VS.80).aspx HTH, Giovanni Thanks, it appears to work. "Giovanni Dicanio" <giovanniDOTdicanio@REMOVEMEgmail.com> wrote in message news:Ose%23WA7mKHA.2544@TK2MSFTNGP04.phx.gbl... > "Don Gurr"...

VB Validating User or Class
Hi, Does anyone have an example of a VB script that shows me how to validate logged in user or the class I would greatly appreciate. Thanks. Hi Magda I have a packge which exposes the toolbar and lets you get the current user id. To get at the class would require you to look up the user id on the SY_User_MSTR table. To do this you would need to use RetrieveGlobals.dll and ADO to send a query to SQL. RetrieveGlobals will also provide the details of the current user id and company. Please have your partner contact me using the address below (remove the online. first) and I can sen...

Can't code a css class that makes a span element the same size as a button element
I want a page where there are buttons all the same size. No problem there. But I also have a type="text" with some text in front. I'd like that combination to be the same size as the buttons. So I put them into to a scan element and applied the same css class to the scan as the buttons have. That didn't work so I modified the code a little as shown below and that does not work either. So I put together the test sample shown below and that does not produce a symetriacl layout. Can you tell me how to fix this? Thanks <%@ Page Title=&q...

Importing Excel database into Outlook Contacts says "No Named Rang
I am trying to import contacts into Outlook from Excell Version 2003. During the process I am getting a message stating that there are No Named Ranges. I have gone to Insert, Name, Define but this doesn't do anything. I can't figure out how to name the ranges. I would apprectiate any help. Thank you Bryan This is how I do it. The basics........Your layout may differ. Instructions here are for Name and Email address only, but adjust to suit for more columns. First have the names and email addresses in Excel in two columns. I set up also a third column with the names dupli...

Disappearing last name
Version: 2004 Operating System: Mac OS X 10.4 (Tiger) Processor: intel With Entourage, Word, Power Point and Excel, after typing my last name and hitting the space bar it disappears. You can imagine how inconvenient this is. Any ideas how I can fix this? Weird. Try looking in Tools | AutoCorrect, preferably in Word, and see if there is an AutoCorrect entry set up to replace your name with anything else. Lois_in_VT@officeformac.com wrote: > Version: 2004 > Operating System: Mac OS X 10.4 (Tiger) > Processor: intel > > With Entourage, Word, Power Point and Excel, after typing...