Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2007

Tip: Looking for answers? Try searching our database.

About error C2248

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank - 29 Sep 2007 15:53 GMT
Hello!
I defined a class(CMyView1) based on CView from class wizard in VC2005, and
there're following code in .h file:

...
...
protected:
    CMyView1();           // protected constructor used by dynamic creation
    virtual ~CMyView1();
...
...

and then in MainFrm.cpp , there're

...
...
CView* pView = (CView*) new CMyView1;  // error C2248
...
...

then the complier reported a error c2248, "cannot access protected member
declared in class 'CMyView1'", how do I solve the problem?

shall I just change the "protected" to "public" ? what's the meaning for the
comment line ? (protected constructor used by dynamic creation)

Thanks a lot!
Frank
Alex Meleta - 29 Sep 2007 16:44 GMT
Hi Frank,

> How do I solve the problem? shall I just change the "protected" to "public"
?
E.g. be creating a public method returning the class instance.

public CView* CreateCView()
{
    return new CMyView1(); // being inside of class it accesses any his
members
}
> what's the meaning > for the comment line ? (protected constructor used
by dynamic
> creation)
It's like the example above - doesn't allow you to create the object manualy,
only by using "factories" or such.

Regards, Alex
[TechBlog] http://devkids.blogspot.com

> Hello!
> I defined a class(CMyView1) based on CView from class wizard in
[quoted text clipped - 25 lines]
> Thanks a lot!
> Frank

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.