Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[C++ Error] main.h(60): E2303 Type name expected

Status
Not open for further replies.

WayneStev

Programmer
Jan 3, 2006
21
US
//---------------------------------------------------------------------------

#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Dialogs.hpp>
#include <FileCtrl.hpp>
#include <ExtCtrls.hpp>
#include <string>

//---------------------------------------------------------------------------
class TfrmMain : public TForm
{
__published: // IDE-managed Components
TDriveComboBox *Drives;
TDirectoryListBox *dir;
TFileListBox *Files;
TLabel *txtPathFile0;
TButton *cmdBaseLine;
TButton *cmdScan;
TLabel *txtHash0;
TButton *cmdExit;
TLabel *txtHash1;
TLabel *txtPathFile1;
TPanel *panGOOD;
TPanel *panBAD;
void __fastcall cmdExitClick(TObject *Sender);
void __fastcall cmdBaseLineClick(TObject *Sender);
void __fastcall cmdScanClick(TObject *Sender);
private:
// User declarations
public: // User declarations
__fastcall TfrmMain(TComponent* Owner);
// void __fastcall GetPutFileAndHashInfo(String s0, long int s1);

// char __fastcall GetTotalTheFile();
};
//---------------------------------------------------------------------------
extern PACKAGE TfrmMain *frmMain;
//---------------------------------------------------------------------------
#endif

struct FileInfo {
String Fname;
long int Hash;
} ;

long int gFileCount;
FileInfo gFileInfo;

class support0 {

public:
virtual void PutFileAndHashInfo(String s0, long int s1);

** void support0 :: PutFileAndHashInfo(s0,s1) {
//TODO: Add your source code here
FILE *Info;
String FName ="hasinfo.ess";
Info = fopen(FName,"a");
fprintf(Info,"%s/n%i",s0,s1);
fclose(Info);
}

};
Iam getting the following error [C++ Error] main.h(60): E2303 Type name expected at the point of the ** what do I need to do ? Help any one !
 
Since you're inside the class, you don't need the support0:: for scope resolution.

Lee
 
OK I removed the referance to support0:: I STILL get the error.
 
Where are the data types of the variables in the parameter list? You have them in the prototype, but not in the actual function.

Lee
 
OK I will try that an other words I need to type the varables in the parameter list in the method (function in the class. I am getting ready to shut down for this week BUT I WILL TRY YOUR SUGGESTION FIRST THING MONDAY I will let you know how it goes
 
I added data types like you suggested. This STILL DID NOT change eoany thing . I am STILL getting the error ???
 
//---------------------------------------------------------------------------

#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Dialogs.hpp>
#include <FileCtrl.hpp>
#include <ExtCtrls.hpp>
#include <string>

//---------------------------------------------------------------------------
class TfrmMain : public TForm
{
__published: // IDE-managed Components
TDriveComboBox *Drives;
TDirectoryListBox *dir;
TFileListBox *Files;
TLabel *txtPathFile0;
TButton *cmdBaseLine;
TButton *cmdScan;
TLabel *txtHash0;
TButton *cmdExit;
TLabel *txtHash1;
TLabel *txtPathFile1;
TPanel *panGOOD;
TPanel *panBAD;
void __fastcall cmdExitClick(TObject *Sender);
void __fastcall cmdBaseLineClick(TObject *Sender);
void __fastcall cmdScanClick(TObject *Sender);
private:
// User declarations
public: // User declarations
__fastcall TfrmMain(TComponent* Owner);
// void __fastcall GetPutFileAndHashInfo(String s0, long int s1);

// char __fastcall GetTotalTheFile();
};
//---------------------------------------------------------------------------
extern PACKAGE TfrmMain *frmMain;
//---------------------------------------------------------------------------
#endif

struct FileInfo {
String Fname;
long int Hash;
} ;

long int gFileCount;
FileInfo gFileInfo;

class support0 {

public:
virtual void PutFileAndHashInfo(String s0, long int s1);

** void PutFileAndHashInfo(String s0,long int s1) {
//TODO: Add your source code here
FILE *Info;
String FName ="hasinfo.ess";
Info = fopen(FName,"a");
fprintf(Info,"%s/n%i",s0,s1);
fclose(Info);
}

};

The above is the current code related to the erroe note line of error. **
 
Maybe you should try void ** instead of ** void???

The simplest solution is the best!
 
OK I can see whare YOU made the error. I sorry but the (**) is NOT part of the code but whare or tbe line the error seems to take place.
 
Did you happen to notice that your #includes are inside of the #ifdef block, but your class definition and FileInfo struct definition are outside of it? Therefore, String, FILE, fopen, fprint and fclose may or may not be defined at that point.
Also when writing your implementation of the class member, you should either write it in the corresponding .cpp file or inline in the class declaration as follows:

Code:
// filename Main.h 

#ifndef mainH
#define mainH

...

class support0 {

public:
        virtual void PutFileAndHashInfo(String s0, long int s1);
};

#endif

Code:
//  filename main.cpp

#include "main.h"
#include<stdio.h>

void support0::PutFileAndHashInfo(String s0,long int s1) {
 //TODO: Add your source code here
FILE *Info;
String FName ="hasinfo.ess";
    Info = fopen(FName,"a");
    fprintf(Info,"%s/n%i",s0,s1);
    fclose(Info);
}

if you're using C++ Builder you're still going to recieve compile errors regarding the String Fname line and a conflict with VCL's AnsiString; still working on those problems.

The simplest solution is the best!
 
I am also faced the same erro and thought tocreate the component by reading the eveloper's guide. u please read the developer guide and implement the sample code...

This mayworks fine for you..

vinay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top