Thread overview
As usual, I'm lost
Jun 27, 2002
Michael Comperchio
Jun 27, 2002
Jan Knepper
Jun 27, 2002
Michael Comperchio
June 27, 2002
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

June 27, 2002
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

June 27, 2002
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