CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: HELP!

  1. #1
    Join Date
    Apr 1999
    Posts
    121

    HELP!

    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


  2. #2
    Join Date
    Jun 1999
    Location
    Canada - Québec
    Posts
    273

    Re: HELP!

    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...


  3. #3
    Join Date
    Apr 1999
    Location
    Toronto, ON
    Posts
    713

    Re: HELP!

    Before this constructor you have to have your
    tmpFiles_

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

    {
    LoadSquelette(IDR_Presences);
    }




    Dmitriy, MCSE

  4. #4
    Join Date
    Aug 1999
    Posts
    7

    Re: HELP!

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured