LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 06: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, 10:05 AM   #2
wapcaplet
LQ 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, 10: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, 10: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, 10:57 AM   #5
wapcaplet
LQ 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, 12: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, 01: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



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-05-2005 11:09 PM
How can I connect to outer sites via proxys to upgrade my debian? LittlesnowLinux Debian 1 11-26-2004 01:09 PM
Server loses contact with outer world Statoilroffe Linux - Networking 0 03-29-2004 11:23 AM
BlackBox.class & VerifierBug.class virus ??? dalek Linux - Security 4 02-29-2004 08:55 AM
Inheriting class members (Qt C++, QApplication class) jtshaw Programming 2 01-15-2004 11:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:29 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
Open Source Consulting | Domain Registration