LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-01-2004, 07:13 AM   #1
Dominik
Member
 
Registered: Nov 2003
Distribution: slackware9.1/freebsd5.2
Posts: 53

Rep: Reputation: 15
Question can't use protected inner class when inheriting the outer


hi,

I'v have extended a class from a librairy. This base-class has a protected inner class. When I try to use it through

Inner inner = baseclass.new Inner()

it fails returning the message that Inner is protected.

So what i have understood about protected inner classes is that they can be used inside the package they belong to & inside a class inheriting the outer base class.

Am I wrong?

thanks
 
Old 02-01-2004, 11:05 AM   #2
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
What language are you programming in?
 
Old 02-01-2004, 11:16 AM   #3
Mahony
Member
 
Registered: Jan 2004
Location: Glasgow
Distribution: Gentoo 2004.0, Debain 3.0r2, Mandrake 10.0 and Slackware 9.1
Posts: 173

Rep: Reputation: 30
YEs that would help, I think it's vb.
 
Old 02-01-2004, 11:38 AM   #4
Dominik
Member
 
Registered: Nov 2003
Distribution: slackware9.1/freebsd5.2
Posts: 53

Original Poster
Rep: Reputation: 15
Oh?!

Sorry,

in java.

thanks
 
Old 02-01-2004, 11:57 AM   #5
wapcaplet
Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
I'm not sure about Java syntax, but I think it should be:

Inner inner = new baseclass().Inner();

This kind of explains it.
 
Old 02-01-2004, 01:44 PM   #6
coolman0stress
Member
 
Registered: Jun 2003
Location: Toronto, Ontario, Canada
Posts: 288

Rep: Reputation: 30
Quote:
So what i have understood about protected inner classes is that they can be used inside the package they belong to & inside a class inheriting the outer base class.
No, they can only be used inside the class that contains it, or any class that extends it [the class that contains the inner]. Protected simply implies that no outside class can actually instance it.

Say, you have a main in your base class, then even in that same package you won't be able to do:
Inner inner = new Inner(); nor new Base.Inner();
Since the Inner class is protected in side the base.

You can however instance it inside any class that extends your Base. So this would work nicely INSIDE the class:
Inner inner = new Inner(); or new baseclass.Inner() if you haven't imported baseclass
And again if you had done this say in your main, it wouldn't work again.
 
Old 02-02-2004, 02:12 AM   #7
Dominik
Member
 
Registered: Nov 2003
Distribution: slackware9.1/freebsd5.2
Posts: 53

Original Poster
Rep: Reputation: 15
thanks for the answers,

it's ok now.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
inheriting permissions steve007 Linux - Security 3 07-06-2005 12:09 AM
How can I connect to outer sites via proxys to upgrade my debian? LittlesnowLinux Debian 1 11-26-2004 02:09 PM
Server loses contact with outer world Statoilroffe Linux - Networking 0 03-29-2004 12:23 PM
BlackBox.class & VerifierBug.class virus ??? dalek Linux - Security 4 02-29-2004 09:55 AM
Inheriting class members (Qt C++, QApplication class) jtshaw Programming 2 01-15-2004 12:52 PM


All times are GMT -5. The time now is 07:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration