Re: Compiler can't see class

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Lilith wrote:
I've trimmed the first part of each line for viewability.

error C2065: 'CMiniExcel' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'MyExcel'
error C2065: 'MyExcel' : undeclared identifier

I assume that the first error promotes the second two.

I've tried with another spreadsheet class (CSpreadSheet) I downloaded
from Code Project with the same predicatable results in that I didn't
change my approach.   I've also tried declaring the class object in
XXXView.cpp with no luck.


Presumably you have something like a MiniExcel.h header file. You must #include "MiniExcel.h" in any source file that uses the symbol CMiniExcel. Think of the compiler as reading each source file from top to bottom. It must (must!) encounter the #include that declares the class before it encounters any use of the class.


--
Scott McPhillips [VC++ MVP]

.



Relevant Pages

  • Re: CRITICAL_SECTION not initialized globally in DllMain
    ... declaring variables in header files is a bad idea. ... In this case, the same header file being included in multiple compilation units causes multiple declarations of the same variable; unless, as when you specified static, the declarations are local scope to the compilation unit. ... > It means each source file gets it's *own* copy of the variable. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: a basic doubt on static functions...
    ... shiva wrote: ... >I have aa basic doubt about declaring function as static. ... static for functions changes the visibility of the function. ... even if the function resides in another source file. ...
    (comp.os.linux.development.system)
  • Re: CRITICAL_SECTION not initialized globally in DllMain
    ... What is the point of declaring a static variable if it's already global. ... Does static global not mean it's valid only in the context of the same source file? ... static CRITICAL_SECTION csCalibrate; ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Static variables.
    ... > static variable outside of the method as oppose to declaring ... appear after it in the source file, ... is visible only within func1(). ...
    (comp.lang.c)
  • Re: about a head line
    ... declaring of the encoding used in the source file. ... you might get an error like: SyntaxError: Non-ASCII ...
    (comp.lang.python)