HELP DUDES! no appropriate default constructor available

Login to reply to this topic.
Thu, 2005-09-22 05:55
Joined: 2005-08-19
Forum posts: 165
Hi all!

I'm trying to create my own class and call it from the appui class.

In my appUI class

void CMyAppUi::ConstructL()
    {

    BaseConstructL();

    iAppContainer = new (ELeave) CMyContainer;
    iAppContainer->SetMopParent( this );
    iAppContainer->ConstructL( ClientRect() );
    AddToStackL( iAppContainer );
 
    iMyClass = new (ELeave) CMyClass;
    iMyClass->ConstructL();

    }

I have declared
class CMyclass
class CMyAppUi : public CAknAppUi
.
.
.
private:
CMyClass* iMyClass;
.
.
.
in the AppUi.h


In my class that I create

CMyClass::CMyClass()
{

}

void CMyClass::ConstructL()
{

   iRecipient=HBufC::NewL(KMaxTelephoneNumberLength); // for recipient sms number
   iMsvId = NULL; // MsvId for keeping track of the message server entries.
   // Create CMsvSession
   iSession = CMsvSession::OpenAsyncL(*this); // new session is opened asynchronously
   
}



When I try to compile my AppUi class, I get this error:

'CMyClass' : no appropriate default constructor available
use of undefined type 'CMyClass'
.
.
.

Is there somtething wrong with the way I construct?
Please Help...

When will I use NewL and NewLC?Huh

Thu, 2005-09-22 07:35
Joined: 2003-12-05
Forum posts: 622
Re: HELP DUDES! no appropriate default constructor available
You didn't show your class declaration in the header file. You didn't show if you included this header file in app ui's header file or in the app ui's cpp file. Did you do all this?

BTW, C -classes that are always allocated dynamically using new (ELeave), should also always inherit directly or indirectly from CBase (and multiple inheritance, except for inheriting interfaces (M-classes) is forbidden).
Thu, 2005-09-22 07:56
Joined: 2005-08-19
Forum posts: 165
Re: HELP DUDES! no appropriate default constructor available
Thanks for your reply..

Oh, yeah. when i included
#include "MyClass.h" in Appui.cpp i got this error:

'iMyClass' : undeclared identifier

but i think i everything was declared.Huh
Thu, 2005-09-22 08:20
Joined: 2005-01-04
Forum posts: 226
Re: HELP DUDES! no appropriate default constructor available
Include "MyClass.h" in AppUi.h rather than in .cpp


BR,
Thu, 2005-09-22 08:26
Joined: 2005-08-19
Forum posts: 165
Re: HELP DUDES! no appropriate default constructor available
Thanks.. I did that..
I still get that error...

Is it because in MyClass.h class declaration:

class CSmsMms : public CEikAppUi,public MMsvSessionObserver
{
public:
.
.
.
.
}

//MMsvSessionObserver is for sms handling

Am I allowed to use  CEikAppUi even though this class is not the AppUI class?Huh
Thu, 2005-09-22 08:48
Joined: 2004-07-28
Forum posts: 1379
Re: HELP DUDES! no appropriate default constructor available
Quote from: bob_marley
Am I allowed to use  CEikAppUi even though this class is not the AppUI class?Huh

I am confused.  Why do you have CMyAppUi deriving from CAknAppUi AND CSmsMms deriving from CEikAppUi?  You only need (and can have) one AppUi.

CSmsMms should be derived from CBase + any other interfaces - inheratance is used for a is-a relationship, if CSmsMms isn't a AppUi, don't derive from one!!! So:

class CSmsMms : public CBase,public MMsvSessionObserver

didster

Thu, 2005-09-22 08:58
Joined: 2005-08-19
Forum posts: 165
Re: HELP DUDES! no appropriate default constructor available
I'm sorry
it is supposed to be like this:

Is it because in MyClass.h class declaration:

class CMyClass : public CEikAppUi,public MMsvSessionObserver
{
public:
.
.
.
.
}

//MMsvSessionObserver is for sms handling

I used CEikAppUi because inside MyClass, i used iEikonEnv->InfoWinL....

or am I not supposed to use it outside the AppUI?Huh

Thanks for your reply Kind souls.
Thu, 2005-09-22 09:11
Joined: 2005-08-19
Forum posts: 165
Re: HELP DUDES! no appropriate default constructor available
I tried to remove AknAppui and everything that uses iEikonEnv..etc from MyClass...

but still I get the error 'iMyClass' : undeclared identifier
when I compile the AppUi class?
How can I make an instance of MyClass from AppUi???
Thu, 2005-09-22 10:16
Joined: 2004-07-28
Forum posts: 1379
Re: HELP DUDES! no appropriate default constructor available
Is this a typo?

class CMyclass;
class ....

private:
CMyClass* iMyClass;

i.e. in your forward declaration you have CMyclass (with a lowecase c) then later on you have CMyClass with an upercase C - that would explain the error as CMyclass != CMyClass so it doesn't know what CMyClass is

didster

Thu, 2005-09-22 10:36
Joined: 2005-08-19
Forum posts: 165
Re: HELP DUDES! no appropriate default constructor available
what a crop! I got this stupid mistake of mislabeling the class name...

Thanks very much guys!

Tips: Be careful when naming or copying and pasting stuff...
Fri, 2005-09-23 06:19
Forum Nokia Champion
Joined: 2005-08-31
Forum posts: 124
Re: HELP DUDES! no appropriate default constructor available
hi marley

i read ur problem can u make me clear of something if u have declared ur class MyAppUI and its object included properly and if ur destroying the object after its usage can u do me a favour give me ur APPUI.Cpp and .h so that i can try it again .I worked on ur code works fine in mine but i'm confused how ur using it

Take care
bye

Mateen Maldar

Mon, 2005-09-26 05:16
Joined: 2005-08-19
Forum posts: 165
Re: HELP DUDES! no appropriate default constructor available
Ok. I'll send u my codes through email. thanks.
Fri, 2005-12-09 15:26
Forum Nokia Champion
Joined: 2005-08-31
Forum posts: 124
Re: HELP DUDES! no appropriate default constructor available
bob u can send ur code to mateen_maldar@hotmail.com so that i'll check it ok

Mateen Maldar

  • Login to reply to this topic.