Click to See Complete Forum and Search --> : HELP!


Sophie
August 16th, 1999, 02:15 PM
I'm trying to pass the reference of tmpFiles. Cold you explain why I'm getting this error...Thank you in advance



#include "ScReportGenerator.h"

class Presences : public CSCReportGenerator
{
public:
Presences();
void GenerateVar( ostream &out, CString Var);
virtual ~Presences();

};
Presences::Presences()
{
LoadSquelette(IDR_Presences);
}


class CSCReportGenerator
{
private:
ParmValues parms;
CSmartClassDoc *doc;
CTmpFileMgr &tmpFiles;

public:
CSCReportGenerator( CTmpFileMgr &tmpFiles_);
void SetParms( CSmartClassDoc *doc_, const ParmValues &parms_);
CString GetParm( const CString &varName);
CSmartClassDoc *GetDoc();
CString AllocTempFile( const CString &pre, const CString &ext);
virtual void Generate(ostream& out);
virtual ~CSCReportGenerator();


protected:
void Parse(istream & in, ostream& out);
virtual void GenerateVar( ostream& out, CString Var) = 0;
void LoadSquelette(WORD fileName);

private:
CString sq;
};
CSCReportGenerator::CSCReportGenerator( CTmpFileMgr &tmpFiles_)
: tmpFiles( tmpFiles_)
{

}



K:\projet2\smartc\SmartClass\Presences.cpp(23) : error C2512: 'CSCReportGenerator' : no appropriate default constructor available

ChristianM
August 16th, 1999, 02:37 PM
i am not sure.... but try to change your construtor "Presences()" by one who derived of CSCReportGenerator.. ex : "Presences(CTmpFileMgr &tmpFiles_);" or "Presences(CTmpFileMgr &tmpFiles_ = NULL);" if you dont want to put 1 parameter...

Dmitriy
August 16th, 1999, 03:48 PM
Before this constructor you have to have your
tmpFiles_

Presences::Presences()
:CSCReportGenerator( CTmpFileMgr &tmpFiles_)

{
LoadSquelette(IDR_Presences);
}




Dmitriy, MCSE

jbennett
August 16th, 1999, 06:16 PM
Presences is a derived class from CSCReportGenerator. Thus, when Presences constructs, it must also construct a CSCReportGenerator.

You have defined the presences ctor as:


Presences::Presences()
{... }




You haven't indicated which ctor of CSCReportGenerator to use, so it tries to use the default ctor CSCReportGenerator() which doesn't exist (hence the error).

The fix would be:
1.) create a default ctor for CSCReportGenerator of the form: CSCReportGenerator(). Not a good choice, bad to muck with the base class...
2.) Make Presences ctor call an existing ctor of CSCReportgenerator:

Presences::Presences() :
CSCReportGenerator(CTmpFileMgr ctfm)
{... }



[possibly a bad idea, we are making the ctor construct a temporary CTmpFileMgr. Necessary since that is required for the ctor, but could have bad consequences.]

Either of these options work. You'll need to analyze the code to see which one makes more sense.