473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Overriding or Hiding.

dmjpro
2,476 2GB
Look at my code carefully.....

Expand|Select|Wrap|Line Numbers
  1. class Super
  2. {
  3.    protected int a;
  4. }
  5. class Derived extends Super
  6. {
  7.  protected int a; //Here Data Overriding or Data Hiding
  8. }
  9.  
Let's look at another example .....

Expand|Select|Wrap|Line Numbers
  1. class Super
  2. {
  3.  public static void test()
  4.  {
  5.     //Some content
  6.  }
  7. }
  8. class Derived extends Super
  9. {
  10.  public static void test() //Here Method Overriding or Method Hiding
  11.  {
  12.    //Some content
  13.  }
  14. }
  15.  
Plz explain .... Hiding and Overrinding for Method and Data ... for both.

Kind regards,
Dmjpro.
Jun 5 '07 #1
4 2329
r035198x
13,262 8TB
Look at my code carefully.....

Expand|Select|Wrap|Line Numbers
  1. class Super
  2. {
  3. protected int a;
  4. }
  5. class Derived extends Super
  6. {
  7. protected int a; //Here Data Overriding or Data Hiding
  8. }
  9.  
Let's look at another example .....

Expand|Select|Wrap|Line Numbers
  1. class Super
  2. {
  3. public static void test()
  4. {
  5. //Some content
  6. }
  7. }
  8. class Derived extends Super
  9. {
  10. public static void test() //Here Method Overriding or Method Hiding
  11. {
  12. //Some content
  13. }
  14. }
  15.  
Plz explain .... Hiding and Overrinding for Method and Data ... for both.

Kind regards,
Dmjpro.
But we've talked about this before, dj. Remember the difference between a class variable and an instance variable.
Jun 5 '07 #2
dmjpro
2,476 2GB
But we've talked about this before, dj. Remember the difference between a class variable and an instance variable.
Ok.
I know we have discussed before.
But it would be better if u discuss again.
Plz.

Kind regards,
Dmjpro.
Jun 5 '07 #3
r035198x
13,262 8TB
Ok.
I know we have discussed before.
But it would be better if u discuss again.
Plz.

Kind regards,
Dmjpro.
You can't override a static

Have a look at the examples in the JLS and decide ...
Jun 5 '07 #4
JosAH
11,448 Expert 8TB
Only non-static methods can be overridden (if they're not final). Everything else
can just be hidden. All methods can be overloaded but that is something completely
different.

kind regards,

Jos
Jun 5 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: AGoTH | last post by:
class A { public: virtual void foo(int b) {} virtual void foo(char* b) {} }; class B : public A{ virtual void foo(int b) {} };
8
by: Massimiliano Alberti | last post by:
Can I specialize a template function in a subclass without overriding it? (the main template function is defined in a base class). Now I'm doing something like that: (in base class)...
1
by: Xiangliang Meng | last post by:
Hi, all. When reading C++ books, I'm alway confused by those terms "redefining functions", "overloading functions" and "overriding functions". Please give me some comments on those terms....
15
by: Susan Baker | last post by:
Hello everybody, I'm new to C++ (I have some C background). I've read up on this topic a few times but it just dosen't seem to be sinking in. 1. Whats the difference between overloading and...
10
by: muscha | last post by:
I don't get it. What's the main differences between overriding a base class's methods vs. hiding them? Thanks, /m
4
by: Rafael Veronezi | last post by:
I have some questions about override in inheritance, and virtual members. I know that you can you override a method by two ways in C#, one, is overriding with the new keyword, like: public new...
4
by: Nilesh | last post by:
I am confused about the purpose of 'new' in overriding. Consider following example. <code_snippet> using console = System.Console; public class TestClass { public static void Main() {
17
by: Bob Weiner | last post by:
What is the purpose of hiding intead of overriding a method? I have googled the question but haven't found anything that makes any sense of it. In the code below, the only difference is that...
1
by: Tariq | last post by:
Any thoughts on how a method on a base class can be prevented from being overriden or hidden? Basically the idea is that no matter what all derived classes should use the method in my base...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.