HELP DUDES! no appropriate default constructor available
| Thu, 2005-09-22 05:55 | |
|
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? ![]() |
|







Forum posts: 622
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).
Forum posts: 165
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.
Forum posts: 226
BR,
Forum posts: 165
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?
Forum posts: 1379
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
Forum posts: 165
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?
Thanks for your reply Kind souls.
Forum posts: 165
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???
Forum posts: 1379
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
Forum posts: 165
Thanks very much guys!
Tips: Be careful when naming or copying and pasting stuff...
Forum posts: 124
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
Forum posts: 165
Forum posts: 124
Mateen Maldar