www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - As usual, I'm lost

↑ ↓ ← Michael Comperchio <mcmprch adelphia.net> writes:
I have declared in a .h file
// shortened
struct DataRecord
{
	int RecordNumber;
	char Task[256];
	char DueDate[10];
	char Priority[2];
	int Completed;
	char Notes[2048];
	int Deleted;
} Data;
//some other stuff...then
struct DataRecord * FindARecord(int iRecordNumber);

in the .cpp i declare this:

struct DataRecord *CFORMAPPDoc::FindARecord(int iRecordNumber){
   struct DataRecord * MyData = new struct DataRecord;
//some code to find the record
   if( rc == true )
     return MyData;
   else
     return NULL;
}

the silly compiler however gives me this:
sc formadoc.cpp -cpp -Ae -mn -C -WA -S -3 -a8 -c -H -HO- -gf -D_DEBUG=1 
-D_X86_=1 -D_MT=1 -Ic:\dm\stl -oformadoc.obj
Error: C:\dm\FORMAPP\formadoc.cpp(241): 'CFORMAPPDoc::FindARecord' 
previously declared as something else
C:\dm\FORMAPP\formadoc.cpp(241): It was declared as: 
CFORMAPPDoc::DataRecord*member func(int )
C:\dm\FORMAPP\formadoc.cpp(241): It is now declared: DataRecord*member 
func(int )
Error: C:\dm\FORMAPP\formadoc.cpp(280): need explict cast to convert
C:\dm\FORMAPP\formadoc.cpp(280): from: CFORMAPPDoc::DataRecord*
C:\dm\FORMAPP\formadoc.cpp(280): to  : DataRecord*
Lines Processed: 378  Errors: 2  Warnings: 0
Build failed


HELP!!!!!

Michael
Jun 27 2002
↑ ↓ Jan Knepper <jan smartsoft.cc> writes:
Michael Comperchio wrote:

 I have declared in a .h file
 // shortened
 struct DataRecord
 {
         int RecordNumber;
         char Task[256];
         char DueDate[10];
         char Priority[2];
         int Completed;
         char Notes[2048];
         int Deleted;
 } Data;
 //some other stuff...then
 struct DataRecord * FindARecord(int iRecordNumber);

I bet that is inside a class CFORMAPPDoc? you do not have the repeat the 'struct' in C++ just DataRecord * FindARecord(int iRecordNumber); will do.
 in the .cpp i declare this:

 struct DataRecord *CFORMAPPDoc::FindARecord(int iRecordNumber){

I suspect that you declared 'DataRecord' within the scope of class CFORMAPPDoc Thus change this to: CFORMAPPDoc :: DataRecord *CFORMAPPDoc::FindARecord(int iRecordNumber){ That might help. Jan
    struct DataRecord * MyData = new struct DataRecord;
 //some code to find the record
    if( rc == true )
      return MyData;
    else
      return NULL;
 }

 the silly compiler however gives me this:

Silly compiler?!
 sc formadoc.cpp -cpp -Ae -mn -C -WA -S -3 -a8 -c -H -HO- -gf -D_DEBUG=1
 -D_X86_=1 -D_MT=1 -Ic:\dm\stl -oformadoc.obj
 Error: C:\dm\FORMAPP\formadoc.cpp(241): 'CFORMAPPDoc::FindARecord'
 previously declared as something else
 C:\dm\FORMAPP\formadoc.cpp(241): It was declared as:
 CFORMAPPDoc::DataRecord*member func(int )
 C:\dm\FORMAPP\formadoc.cpp(241): It is now declared: DataRecord*member
 func(int )
 Error: C:\dm\FORMAPP\formadoc.cpp(280): need explict cast to convert
 C:\dm\FORMAPP\formadoc.cpp(280): from: CFORMAPPDoc::DataRecord*
 C:\dm\FORMAPP\formadoc.cpp(280): to  : DataRecord*
 Lines Processed: 378  Errors: 2  Warnings: 0
 Build failed

 HELP!!!!!

 Michael

Jun 27 2002
↑ ↓ → Michael Comperchio <mcmprch adelphia.net> writes:
Jan Knepper wrote:
 Michael Comperchio wrote:
 
 
I have declared in a .h file
// shortened
struct DataRecord
{
        int RecordNumber;
        char Task[256];
        char DueDate[10];
        char Priority[2];
        int Completed;
        char Notes[2048];
        int Deleted;
} Data;
//some other stuff...then
struct DataRecord * FindARecord(int iRecordNumber);

I bet that is inside a class CFORMAPPDoc? you do not have the repeat the 'struct' in C++ just DataRecord * FindARecord(int iRecordNumber); will do.
in the .cpp i declare this:

struct DataRecord *CFORMAPPDoc::FindARecord(int iRecordNumber){

I suspect that you declared 'DataRecord' within the scope of class CFORMAPPDoc Thus change this to: CFORMAPPDoc :: DataRecord *CFORMAPPDoc::FindARecord(int iRecordNumber){ That might help. Jan
   struct DataRecord * MyData = new struct DataRecord;
//some code to find the record
   if( rc == true )
     return MyData;
   else
     return NULL;
}

the silly compiler however gives me this:

Silly compiler?!
sc formadoc.cpp -cpp -Ae -mn -C -WA -S -3 -a8 -c -H -HO- -gf -D_DEBUG=1
-D_X86_=1 -D_MT=1 -Ic:\dm\stl -oformadoc.obj
Error: C:\dm\FORMAPP\formadoc.cpp(241): 'CFORMAPPDoc::FindARecord'
previously declared as something else
C:\dm\FORMAPP\formadoc.cpp(241): It was declared as:
CFORMAPPDoc::DataRecord*member func(int )
C:\dm\FORMAPP\formadoc.cpp(241): It is now declared: DataRecord*member
func(int )
Error: C:\dm\FORMAPP\formadoc.cpp(280): need explict cast to convert
C:\dm\FORMAPP\formadoc.cpp(280): from: CFORMAPPDoc::DataRecord*
C:\dm\FORMAPP\formadoc.cpp(280): to  : DataRecord*
Lines Processed: 378  Errors: 2  Warnings: 0
Build failed

HELP!!!!!

Michael

--

Thanks Jan, That's the ticket. Too many subtle differences in declaration syntax for my two brain cells to get...repetition is the key to learning eh? Michael
Jun 27 2002